Reputation: 3259
I have the following regular expression tested at regex101 and it works there. However, when I try to use it inside the preg_match it doesn't work anymore. The problem is the slash: I tried escaping it but I can't get it working.
preg_match("/[<>\\\"'%;()&]/", "my\string");
The set of characters that I should match are:
< > \ " ' % ; ( ) &
Upvotes: 1
Views: 217
Reputation: 9445
Simply use a different delimiter:
preg_match("![<>\\\"'%;()&/]!", "my\string");
Upvotes: 4