in reply to Re^2: CSV regex with hash/array program plan
in thread CSV regex with hash/array program plan
when ((s/(\b[A-E]{3}\b)/XXX/g)) {@array[i,1] = $1}
Capture groups don't work the same way in s/// substitution versus m// matching:
Capture groups work in a potentially surprising way in s/// substitution and m// matching:
(note that only the last group matched is captured). Please see perlre, perlrequick, and perlretut.c:\@Work\Perl>perl -wMstrict -le "my $s = 'xxx aBc yyy dE zzz'; print qq{\$s: '$s'}; ;; print qq{\$1: '$1'} if $s =~ s{ ([AaBbCcDdEe]+) }{XXX}xmsg; print qq{\$s: '$s'}; " $s: 'xxx aBc yyy dE zzz' $1: 'dE' $s: 'xxx XXX yyy XXX zzz'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: CSV regex with hash/array program plan
by Anonymous Monk on Nov 24, 2014 at 01:16 UTC |