in reply to Arbitrary number of captures in a regular expression
That assumes there is only one delimiting pair of "foo" ... "bar"per string.while ( <DATA> ) { my ( $core) = /^foo (.*) bar$/; my @nums = $core =~ /m (\d+)/g; print "$core -> (@nums)\n"; } __DATA__ foo m 1 m 2 m 3 m 4 bar foo m 2 m 4 m 7 bar foo m 1 bar
Anno
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Arbitrary number of captures in a regular expression
by bart (Canon) on Sep 24, 2007 at 09:07 UTC |