function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Srinivasa Amarendra Reddy VakaSrinivasa Amarendra Reddy Vaka 

Validation Rule Regex to allow specific characters in a text field

Hi All,

I have a text field and would like to add a validation rule so users can only enter a certain set of characters in it. But my validation rule is failing with Syntax error here. Can someone help?

REGEX(field ,
"([a-zA-Z0-9 .?!,;:_@&/\'"`~()<>$#%])*")

Basically, it should allow alphanumeric characters including spaces AND any of the special characters that are listed here "Period
Question Mark
Exclamation Point
Comma
Semi-colon
Colon
Underscore
At Sign
Ampersand
Forward Slash
Back Slash
Apostrophe
Quote
Grave Accent
Tilde
Left Parenthesis
Right Parenthesis
Less Than
Greater Than
Dollar Sign
Pound/Number
Percent".

Regards
Amar
SUCHARITA MONDALSUCHARITA MONDAL

Hi Amar,

Please check with below RegEx

"([a-zA-Z0-9 .?!,;:_@&/\'"`~()<>$#%])*"

It should be working. 

Thanks
Sucharita

Srinivasa Amarendra Reddy VakaSrinivasa Amarendra Reddy Vaka
Hi Sucharita,

Thank you for the response. I just compared your regex and mine, I am unable to see any differences. can you please tell me what was changed?

REGEX(field ,"([a-zA-Z0-9 .?!,;:_@&/\'"`~()<>$#%])*")   ===> Mine
                       "([a-zA-Z0-9 .?!,;:_@&/\'"`~()<>$#%])*"   ===>  Yours


Regards
Amar
SUCHARITA MONDALSUCHARITA MONDAL

Hi,

Please check the following :

REGEX( Status__c ,'([a-zA-Z0-9 .?!,;:_@&/\'"`~()<>$#%])')

Hope this helps

Thanks,
Sucharita