Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: regular expression help

by kennethk (Abbot)
on Jun 03, 2009 at 19:31 UTC ( [id://768128]=note: print w/replies, xml ) Need Help??


in reply to regular expression help

Assuming I understand your spec, the solution to your issue would appear to be quantifiers, specifically '?' which matches 0 or 1 occurrences of a patten, combined with the extended pattern '(?:...)', which will allow grouping without capturing. For your provided examples, this works for me:

$str =~ /(?:<\*\d+>)?([^<]+)<(\d+):(\d+)>,<\*\d+>([^<]+)<(\d+):(\d+)>/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found