in reply to RE: RE: Selective substitution: not in Perl?
in thread Selective substitution: not in Perl?
would give:my string = "foo_a_foo_b_foo_c_foo_d_foo_e_foo_f_foo" my $pattern = "foo" my $better = "bar" my $n = 1; $string =~ s/^(($pattern.*){$n})$pattern/$1$better/;
not"foo_a_foo_b_foo_c_foo_d_foo_e_foo_f_bar"
"foo_a_bar_b_foo_c_foo_d_foo_e_foo_f_foo"
Nuance
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: RE: RE: Selective substitution: not in Perl?
by davorg (Chancellor) on Aug 16, 2000 at 14:51 UTC |