I’m trying to parse a line with negative lookahead but I’m having trouble understanding it.
So, if I have a line such as int a = sincos(a, &a);
How can I use regex to parse the line above such that it matches all the a except the one with &?
thanks.
I think you are actually interested in negative lookbehind here. You want instances of
athat are not preceded by&.This pattern looks for instances of
athat are separated by word boundaries\band are not immediately preceded by an ampersand(?<!&).Including the word boundaries prevents matching
ain the middle of other words, otherwise you’d have 5 matches in something like this: