I am trying to create a regex that helps Eclipse’s search find all lines that contain start( except for ones that are comment lines.
That is, find lines like:
is not sufficient because it doesn't guarantee that start(b) is
But not lines like:
* is not sufficient because it doesn't guarantee that start(b) is
I have been able to come up with the regex (\s*?)(?!\*)(.*)(start\()(.*$) but it finds both lines.
How do I exclude the line that starts with * (possibly after some whitespace) and include lines that don’t have that?
For a line beginning with whitespace, it would be possible for the
\s*?to match zero whitespaces, then the(?!\*)to match a whitespace, and the.*trailer to match the rest of the line including asterisk.A solution would be to put the leading-whitespace preamble inside the negated clause:
Alternatively you could use a possessive quantifier to eat all the whitespaces and never backtrack: