in reply to Arbitrary number of captures in a regular expression
It's not fancy or general, but it's simple and
may be adaptable to your purpose:
1) Where "any number" is equal to 5...$ms = '(?: m (\d+))?' x 5; # 1) print join(",", /^foo$ms bar$/ ),"\n" for ( 'foo m 1 m 2 m 3 m 4 bar', 'foo m 2 m 4 m 7 bar', 'foo m 1 bar', ); __END__ 1,2,3,4, 2,4,7,, 1,,,,
|
---|
In Section
Seekers of Perl Wisdom