in reply to Replacing a specfied instance of a pattern in a string
One way:
Caution: Contents may have been coded under pressure.
my $foo = 'Fsih my test variable is fsihd or is it gfsih or gfsihd fsi +h'; # Replace the 3rd $foo =~ s/((?:fsih.*?){2})fsih/$1fish/i or warn "Not found"; print "Foo = $foo\n";
Caution: Contents may have been coded under pressure.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Replacing a specfied instance of a pattern in a string
by GrandFather (Saint) on Jul 15, 2005 at 01:08 UTC |
In Section
Seekers of Perl Wisdom