Do you know where your variables are? | |
PerlMonks |
Re: regular expression helpby kennethk (Abbot) |
on Jun 03, 2009 at 19:31 UTC ( [id://768128]=note: print w/replies, xml ) | Need 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+)>/
In Section
Seekers of Perl Wisdom
|
|