Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: String manipulation

by abhy (Novice)
on Jun 24, 2009 at 10:42 UTC ( #774340=note: print w/ replies, xml ) Need Help??


in reply to Re: String manipulation
in thread String manipulation

If I am not asking for too much, can you please expand the regex with comments?


Comment on Re^2: String manipulation
Re^3: String manipulation
by citromatik (Curate) on Jun 24, 2009 at 11:22 UTC

    Sure:

    my $rx = qr/ ^ # At the beginning of the string ( # Capture in $1 (?: # Paren for grouping (don't capture in $2) \w # match a "wordy" character (?: # paren for grouping, \s+|\z # match at least one space or the end of the + string ) )* # zero or more times ) # end of capture $1 (.*) # and match what comes after storing it in $ +2 /x # allow these comments ;

    The rationale is to match at the beginning all the one-character strings, storing them in $1. The rest of the input will be catched in $2

    citromatik

Re^3: String manipulation
by Limbic~Region (Chancellor) on Jun 24, 2009 at 13:03 UTC
    abhy,
    If you don't know about YAPE::Regex::Explain, it is worth a look. I don't think it has been updated to take into consideration the new regex doodads in Perl 5.10 but it should be helpful regardless.

    Cheers - L~R

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (15)
As of 2015-07-02 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (33 votes), past polls