Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: how to search and replace the match with specific number of times in a string

by JavaFan (Canon)
on Jan 29, 2010 at 11:07 UTC ( [id://820338]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $string =~ s/a/i/ for 1 .. $N;
    
  2. or download this
    my $count = 0;
    $string =~ s/a(??{++ $count <= $N ? "(*ACCEPT)" : "(*FAIL)"})/i/g;
    # Use '""' instead of '(*ACCEPT)' and '(?!)' instead of '(*FAIL)' on o
    +ld Perls.
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (11)
As of 2024-04-23 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found