About
Regular expression is a language that does not have a NOT operator but it has some negative construct
Articles Related
Construct
Negative Class
^ will negate the class, ie capture until not this characters
Example:
- matches any character other than a, b, or c.
[^abc]1
- matches any single character that is not a lowercase letter from a to z. |
[^a-z]1
- all character except the character p
[^p]*
Negative Look
- Negative lookahead - do we have a pattern ahead
- Negative lookbehind - do we have a pattern behind
See Regexp - Look-around group (Assertion) - ( Lookahead | Lookbehind )
Example:
- Positive lookahead: Capture only if the string has a ?
(?=\?)(.*)