Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Help with Perl RE

by toolic (Bishop)
on Jan 22, 2009 at 17:23 UTC ( [id://738231]=note: print w/replies, xml ) Need Help??


in reply to Help with Perl RE

There is also a tool to help understand Perl regular expressions: YAPE::Regex::Explain. It will at least explain what is inside the regex delimeters.
use warnings; use strict; use YAPE::Regex::Explain; my $re = '^([^{};]+[{};])(\s*\S+.*)$'; print YAPE::Regex::Explain->new($re)->explain();
The regular expression: (?-imsx:^([^{};]+[{};])(\s*\S+.*)$) 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 and capture to \1: ---------------------------------------------------------------------- [^{};]+ any character except: '{', '}', ';' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- [{};] any character of: '{', '}', ';' ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- ( group and capture to \2: ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \S+ non-whitespace (all but \n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \2 ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2025-04-19 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.