in reply to RE: Selective substitution: not in Perl?
in thread Selective substitution: not in Perl?
I was going to give a similar solution, but then I realised that the previous (non-replaced) matches didn't necessarily have to be consecutive in the original string. Perhaps you you need to put optional separator space in the regex. Something like...
--$string =~ s/^(($pattern.*){$n})$pattern/$1$better/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: RE: Selective substitution: not in Perl?
by nuance (Hermit) on Aug 16, 2000 at 14:49 UTC | |
by davorg (Chancellor) on Aug 16, 2000 at 14:51 UTC |