Not quite sure how to go about this, but basically what I want to do is match a character, say a
for example. In this case all of the following would not contain ma
You may use a combination of a lookbehind and a lookahead:
(?
See the regex demo and the regex graph:
Details
(? - a negative lookbehind that fails the match if, immediately to the left of the current location, there is a a
char
a
- an a
char(?!a)
- a negative lookahead that fails the match if, immediately to the right of the current location, there is a a
char.