http://www.perlmonks.org?node_id=768141


in reply to Re: regular expression help
in thread regular expression help

...consider splitting...
Or define your X subpattern as a separate regex, then build the pattern with it:
my $subpat = qr/(?:<\*\d+>)?([^<]+)<(\d+):(\d+)>/; $str =~/$subpat(?:,$subpat)*/;
However, the capturing parentheses are not going to capture everything this way.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^3: regular expression help
by ikegami (Pope) on Jun 03, 2009 at 20:30 UTC

    However, the capturing parentheses are not going to capture everything this way.

    That's why I didn't recommend it. Perl's match operator can match extremely complex expressions (the initial purpose of regular expressions) and it can extract data from strings, but it's not so good at doing both at once. (At least not before 5.10. 5.10 added a bunch of tools that might help.)

Re^3: regular expression help
by pip9ball (Acolyte) on Jun 03, 2009 at 22:36 UTC
    Thanks for the suggestion...I will try doing something like this!