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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Match a pattern only if it is not within another pattern
by Transient (Hermit) on Aug 16, 2005 at 19:51 UTC | |
Re^2: Match a pattern only if it is not within another pattern
by punkish (Priest) on Aug 16, 2005 at 19:53 UTC |
In Section
Seekers of Perl Wisdom