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 ( [id://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?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-28 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found