I am not good with regular expression patterns. I have to put a validation on an string, to allow
only alphabets, numbers, decimals, spaces, comma and underscore
for allowing the alphabets and spaces I have /^[a-zA-Z][a-zA-Z\\s]+$/
Please help me in creating all the above conditions in one pattern.
Thanks
this regex should work for your requirements
'[a-zA-Z0-9_. ,]*'
In the regex, I specified the range a to z, A to Z (uppercase), 0 to 9 and the single character _, decimal point ".", space and a comma.
If you want to make sure you want at least one character after the first letter, you can replace the * with a +, or {2,} with at least 2 more characters, or {2,5} with between 2 and 5 characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With