Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: (bbfu) (another way) Re: Replacing a given character starting with the xth occurence in a string

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

Help for this page

Select Code to Download


  1. or download this
    print mine ("Terence and Philip are sweet", 'c', 'Z', 3);
    
  2. or download this
    sub crep {
      my ($str, $chr, $rep, $nth) = @_;
    ...
      substr ($str, $pos) =~ s/$chr/$rep/g if $pos >= 0;
      return $str;
    }
    
  3. or download this
    sub crep {
      my ($str, $chr, $rep, $num) = @_;
    ...
      $str =~ s/$chr/$rep/g;
      $tstr.$str;
    }
    
  4. or download this
    sub crep {
      my ($str, $chr, $rep, $num) = @_;
    ...
      substr ($str, -1 + pos $str) =~ s/$chr/$rep/g;
      return $str;
    }
    
  5. or download this
    sub crep {
      my ($str, $chr, $rep, $nth) = @_;
    ...
      substr ($str, $pos) =~ s/$chr/$rep/g;
      return $str;
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-26 07:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found