in reply to Re: Replacing a specfied instance of a pattern in a string
in thread Replacing a specfied instance of a pattern in a string
my $foo = 'Fsih my test variable is fsihd or is it gfsih or gfsihd f +sih'; my $from = 'fsih'; my $which = 3; my $to = 'FISH'; # makes it easy to see $foo =~ /\Q$from\E/ig for (1..$which); substr($foo, pos($foo) - length($from), length($from), $to) if pos($fo +o); print "Foo = $foo\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Replacing a specfied instance of a pattern in a string
by ikegami (Patriarch) on Jul 14, 2005 at 22:48 UTC |