Hi ,

I have a Input block with input type as Text. I want to apply regex to filter out numeric numbers and Special characters on keypress  for web Development.(eg., Name inputfield must take only Alphabets).

I don't know how to use Regex . please help.

Hey Harish,

A useful site to learn and test regex is: https://regex101.com/

You could use either:


To only match the alphabetical characters, or use:


To only match numerics on which you can use a regex_replace to replace them to "".

Hi Harish,

Why do you want to use Regex if you don't know how to use Regex?

Kilian Hekhuis wrote:


Can you tell me another solution of my above problems. 

Hi Harish,

Why do you want to use Regex if you don't know how to use Regex?

Well, personally, I wouldn't want to filter out anything, but just let the user know that they typed in invalid input. Of course, regex is the most useful tool for that :). The thing is though, that regex is pretty difficult to grasp, and filtering out characters need a regex replace (also in the Text Extension), which might be even more difficult to use.

You could also use the extended attribute "pattern" on inputs, though this is a client-side validation and therefore can easily be exploited by a malicious user. 


Therefore it is recommended that you always have some form of server-side validation.

Hi Harish,

I'd take a look at Custom Input Masks forge component, to start. That would help you provide a better UX to your users, although it may still be bypassed by the informed user.

As for regex, you will need to add a dependency to the Text extension, and possibly use the patterns suggested by Joey with the actions Regex_Replace and Regex_Search.

Keep in mind that depending on the language, names can have all sorts of valid characters that are not just 'a' through 'z' or 'A' through 'Z', namely characters with diacritical marks are common in many different scripts, and some names also have other embedded symbols (like apostrophes, hyphens, etc).

I'd be wary of filtering out anything and stopping my users from inserting valid data (really breaks someone's experience).