Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Re: Regex (lookahead) Confusion

by Anonymous Monk
on Feb 05, 2004 at 22:40 UTC ( [id://326918]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Regex (lookahead) Confusion
in thread Regex (lookahead) Confusion

perl -MYAPE::Regex::Explain -e 'print YAPE::Regex::Explain->new(q/^(?: +([smtwhfa])(?!.*\1))*$/)->explain' The regular expression: (?-imsx:^(?:([smtwhfa])(?!.*\1))*$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- (?: group, but do not capture (0 or more times (matching the most amount possible)): ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- [smtwhfa] any character of: 's', 'm', 't', 'w', 'h', 'f', 'a' ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- (?! look ahead to see if there is not: ---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \1 what was matched by capture \1 ---------------------------------------------------------------------- ) end of look-ahead ---------------------------------------------------------------------- )* end of grouping ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

Replies are listed 'Best First'.
Re: Re: Re: Re: Regex (lookahead) Confusion
by ChrisR (Hermit) on Feb 06, 2004 at 13:40 UTC
    Wow, I wish I had known about YAPE::Regex::Explain a long time ago. This will provide a much greater understanding of regexes and faster troubleshooting. All hail japhy!!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-18 22:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found