Reputation: 11319
How can I write a Regular Expression to match,
a string which does not contain the underscore "_".
Upvotes: 1
Views: 9199
Reputation: 176803
To match a character that is not an underscore you'd use [^_]
(the ^
means "not"). So to match a whole string you'd do something like this:
/[^_]+/
Upvotes: 0
Reputation: 45002
/^[^_]*$/
The [^] syntax means "do not include any of these characters".
Upvotes: 10