<div dir="ltr"><div>Hello All,<br><br>I have an interesting challenge with a regex.  I need to match any line that:<br>    Does not contain a !  or a # as the first non-whitespace character<br>    Contains the word 'if', but not the string "-if" or the string "ifdef"<br><br>So this should match:<br><br>"    if a=1 then"<br><br>These should not match:<br><br>"!* If this code runs..."<br>"#ifdef something"<br>"    !If this code runs..."<br><br>Here's the regex I have so far:<br><br>^\s*[^!#].*[^-]if[^a-zA-Z0-9_].*<br><br>This works for the most part, except it is matching lines that begin with any number of whitespaces and an exclamation point.  So it incorrectly matches this, for example:<br><br></div>"      ! if you have a comment..."<br><div><div><br><br>This is undesired behavior.<br><br>What am I missing here?<br><br>Thanks!<br>-JK<br></div></div></div>