..while this only prints out the "test new line" one for some reason?
while ($test =~ s{$re}{}ge) {
print "BLA: $1 \n";
}
That is because s///g ignores context and just does all the replacements at once leaving the last match in $1.
But m//g in scalar context will iterate through each match every time it is called in scalar context so that in a while loop $1 will contain each match in turn.
In reply to Re^5: Regex question - negatives
by jwkrahn
in thread Regex question - negatives
by ultranerds
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |