Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Replacing a specfied instance of a pattern in a string (2 more)

by tye (Cardinal)
on Jul 15, 2005 at 05:17 UTC ( #475118=note: print w/ replies, xml ) Need Help??


in reply to Replacing a specfied instance of a pattern in a string

my $i= 0; $str =~ s/(...)/ 3 == ++$i ? 'fish' : $1 /ge;
or
my $i = 3; 0 while $str =~ /fsih/gi && --$i; substr( $str, $-[0], $+[0]-$-[0], 'fish' ) if ! $i;

- tye        


Comment on Re: Replacing a specfied instance of a pattern in a string (2 more)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://475118]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2015-07-03 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls