Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Replacing a given character starting with the xth occurence in a string

by ZZamboni (Curate)
on May 21, 2001 at 04:16 UTC ( [id://81887]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $n=2;    # x-1
    $chr="e";
    $rep="1";
    $a="Terence and Philip are sweet";
    while ($a=~s/^((?:.*?$chr){$n})(.*?)$chr/$1$2$rep/) {}
    
  2. or download this
    1 while ($a=~s/^((?:.*?$chr){$n})(.*?)$chr/$1$2$rep/);
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-24 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found