Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by ZZamboni (Curate)
on May 22, 2001 at 04:09 UTC ( #82140=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @q = split(/(.*?)/, $p);
    
  2. or download this
    @q = split(//,$p);
    
  3. or download this
    foreach (@q) {
    
  4. or download this
    @q = split (//, $p);
    foreach (@q) {
    ...
    }
    $out = join ("", @q);
    print "out === $out";
    
  5. or download this
    foreach (@q) {
        if ($_ eq $matchchar) {
    ...
            }
        }
    }
    
  6. or download this
    foreach (@q) {
        if ($_ eq $matchchar && ++$count >= $nummatch) {
           $_ = $repchar;
        }
    }
    
  7. or download this
    foreach (@q) {
       $_ = ($_ eq $matchchar && ++$count >= $nummatch)?$repchar:$_;
    }
    
  8. or download this
    @q = map { ($_ eq $matchchar && 
                ++$count >= $nummatch)?$repchar:$_ } @q;
    
  9. or download this
    @q = map { ($_ eq $matchchar && 
                ++$count >= $nummatch)?$repchar:$_ }
         split(//, $p);
    
  10. or download this
    $out = join ("",
               map { ($_ eq $matchchar &&
                      ++$count >= $nummatch)?$repchar:$_ }
                  split (//, $p));
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2021-12-02 10:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (18 votes). Check out past polls.

    Notices?