With ^
, which negates a character set.
You want /[^a-z0-9]/i
.
[a-z]
matches a..z. [^a-z]
matches anything not a..z.
Question
I'm looking for a pattern that will match anything but this:
"/[a-z0-9]/i"
How can i do that?
Solution
With ^
, which negates a character set.
You want /[^a-z0-9]/i
.
[a-z]
matches a..z. [^a-z]
matches anything not a..z.
OTHER TIPS
/[^a-z0-9]/i
The ^
at the start inside a [ ]
means "none of these" rather than the conventional "any of these"
If he wants something matches not a-z0-9 one time, this is it. this matches spaces, everything that isn't a-z0-9, one time