in reply to Re: RegEx Beginning of line or whitespace match
in thread RegEx Beginning of line or whitespace match

See, I knew this wasn't as difficult to the level I was struggling with it. This works, because I forgot two additional test cases...that being that this could be anywhere in the line, not just at the beginning with or without spaces. e.g.
$line = 'could be anything here some_for($var)'; #don't match $line = 'could be anything here for($var)'; #match
Thanks.

Replies are listed 'Best First'.
Re^3: RegEx Beginning of line or whitespace match
by CountZero (Bishop) on Feb 11, 2005 at 22:50 UTC
    In other words: match if for( begins at a word boundary, don't match in all other cases:
    m/\b(for\()/
    PS: you can drop the parentheses if you don't want to extract anything and only want to test for matches.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law