$str =~ s/((?<!bar)\S*)foo(\S*(?!qux))/${1}123${2}/gx; print "$str\n";
prints
bl123 and barthis123thatqux and barso123quxhim and123som 123
In reply to Re^2: Match a pattern only if it is not within another pattern
by punkish
in thread Match a pattern only if it is not within another pattern
by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |