in reply to Repeating a capture group pattern within a pattern
Maybe I'm missing something, but this doesn't seem too difficult:
> perl -e 'my $x = "0.01 NaN 2.30 4.44"; my ($d, $e, $f, $g) = ($x =~ /([Na0-9\.\-\0]+\b)/g); print "d: $d, e: $e, f: $f, g: $g";'
output:
d: 0.01, e: NaN, f: 2.30, g: 4.44
the /g flag makes it return a list of all matches.
I changed \s+ to \b (word-boundary) since the last piece doesn't have a space after it
|
---|