Negations in Regex
Writing by shivdev on Friday, 26 of May , 2017 at 6:43 pm
If you are in the situations where you know what NOT to look for, but everything else is considered a match, then you need to negate the pattern and use something like this as explained on this permonks thread.
^(?:(?!PATTERN).)*$
^(?:(?!nope|no|not|never|negate|negation).)*$
Here’s an example in Sublime Text.
Leave a comment
Category: Uncategorized
- Add this post to
- Del.icio.us -
- Digg -
- -
- Tweet -
-
-