Hi All,
I'm using Regex Search in my application and I want to allow users to add ' _ ' (Underscore ) also with their Names.
I'm able to use ' - & , ' but if I'm using ' _ ' then it is showing me this error.
Kindly help in this.
Hi Saransh,
Can you try the below-mentioned Regex pattern for your use case?
"^[\w \-\&\,]+$"
Note: \w is equivalent to [A-Za-z0-9_]
See this sample screen: RegexTask
I hope this helps you!
Kind regards,
Benjith Sam
ok let me try this one
The underscore character is already included in the \w i.e. \w (word character) matches any single letter, number or underscore (same as [a-zA-Z0-9_] )
It is working man how did you find it? What was your strategy to find this?
No as such unique strategy to mention. I just referred to multiple related posts (Google search) and then trailed and tested multiple patterns to draft the final pattern ;)
Glad that it helped you :)
Still, it's pretty silly not to be able to escape an underscore.....