RegexMatcher for Special Characters

I want to identify if there are any invalid characters in my records. Only below special characters are valid
"[a-zA-Z][0-9]^_=!#$%&()*+,-.:'/?@ ")

If any other special character appears other than above, it needs to say false.

Eg: In the above special characters, there is no “|,~”. If my word contains |,~ it needs to written false.

Hi @sundhuk,

I think you could use a Rule Engine with a rule such as this:

NOT $column1$ MATCHES "^[a-zA-Z0-9\^_=\!#\$%&\(\)\*\+\-\.:'/\?@ ]*$" => FALSE
TRUE => TRUE

Note that I haven’t included comma in this list. You had it both in your allowed and disallowed list but as you’d mentioned it in disallowed, I assume its presence in the first list was a typo.

For all the regex characters that have “special meaning”, they have to be escaped with a preceding back-slash \ characters (I hope I got them all!), and the entire list of allowed characters is enclosed in [ ] square brackets. This will also allow empty strings (zero characters). If you don’t want to allow the string to be empty replace the * at the end with a +.

5 Likes

Thanks @takbb . Solution worked :slight_smile:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.