Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude comma character from a non-whitespace string

I need a regex expression that will validate that a string is not all whitespace and that it does not include the comma (,) character.

I've been able to find examples that do one or the other, but not both:

^(?![\s,]*$).+ to insure not all white space and
^(.(?!,))*$ to exclude commas.

I don't have the option of using code, this is a constraint on a field in a form.

like image 461
user2213422 Avatar asked Mar 26 '13 21:03

user2213422


1 Answers

This should suit your needs:

^[^,]*[^ ,][^,]*$

"At least one char that is not a space nor a comma, surrounded by any char but a comma"

like image 174
sp00m Avatar answered Oct 09 '22 21:10

sp00m