in reply to Match a pattern only if it is not within another pattern
Use negative look-behind and negative lookahead.
Update: Yup - it's broke. Nothing to see here, move along.$str =~ s/((?<!bar)\S*)foo(\S*(?!qux))/${1}123${2}/gx;
pbeckingham - typist, perishable vertebrate.
In Section
Seekers of Perl Wisdom