Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: RegEx Beginning of line or whitespace match

by THRAK (Monk)
on Feb 11, 2005 at 21:46 UTC ( [id://430304]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://430304]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found