Regex for “AND NOT” operation [duplicate]

This will match any character that is a word and is not a p:

((?=[^p])\w)

To solve your example, use a negative look-ahead for “My” anywhere in the input, ie (?!.*My):

^(?!.*My)((?<=(so|me|^))big(com?pl{1,3}ex([pA]t{2}ern)

Note the anchor to start of input ^ which is required to make it work.

Leave a Comment