Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by MeowChow (Vicar)
on May 21, 2001 at 10:30 UTC ( [id://81925]=note: print w/replies, xml ) Need Help??


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

Eh, you didn't actually test this, did you? =)

See my reply to bbfu above. You'd have to do something like:

sub adv_tr { my ($str, $x, $from, $to) = @_; my $pos = -1; ($pos = index($str, $from, $pos + 1)) == -1 and return $str while $x +--; eval "substr(\$str, $pos) =~ tr/\Q$from\E/\Q$to\E/"; $str; }
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print
  • Comment on Re: Re: Replacing a given character starting with the xth occurence in a string
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Replacing a given character starting with the xth occurence in a string
by japhy (Canon) on May 21, 2001 at 17:55 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-19 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found