$rex = \'/^[^<,\"@?=>|;#]$/i\';
I\'m having trouble with this regular expression. The idea is that the input fields are checked for certain chara
What you probably actually need is:
$rex = '/[<,"@$?=>|;#]/';
Then your error case is when this regex matches, not when it doesn't.
This is equivalent to doing what you're currently doing with this small change to your regex:
$rex = '/^[^<,"@?=>|;#]*$/i';
This is kind of nonsensically overcomplex, though. Like trying to find out whether there's an elephant in the room by counting how many things in the room aren't elephants, then seeing if that number is the same as the number of things in the room. (And the /i
modifier is not, at any time, accomplishing anything.)