Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: regular expression

by tj_thompson (Monk)
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 '$'.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2021-04-13 02:05 GMT
Find Nodes?
    Voting Booth?

    No recent polls found