http://qs321.pair.com?node_id=484226


in reply to Match a pattern only if it is not within another pattern

Use negative look-behind and negative lookahead.

$str =~ s/((?<!bar)\S*)foo(\S*(?!qux))/${1}123${2}/gx;
Update: Yup - it's broke. Nothing to see here, move along.



pbeckingham - typist, perishable vertebrate.