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