Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: regular expression

by tj_thompson (Scribe)
on Aug 03, 2012 at 18:33 UTC ( #985305=note: print w/ replies, xml ) Need Help??


in reply to Re: regular expression
in thread regular expression

While this will work for this string, we're obviously dealing with a perl novice here and this solution is difficult to understand at best for someone learning the language.

If you're ever uncertain as to why your regex is not working, put a capture '()' around each element of the regex and dump them out. You'll see exactly which regex elements are matching which pieces of your string. This will give you a lot of insight into what might be going wrong. Also be sure that you check the return value of your match is true. You might not be matching at all.

As pointed out by many previous posters, I recommend the OP research greedy and non-greedy matches. Also read up on anchoring regexes with '^' and '$'.


Comment on Re^2: regular expression

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2014-07-13 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (247 votes), past polls