Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by rubasov (Friar)
on Jan 29, 2010 at 12:04 UTC ( #820349=note: print w/ replies, xml ) Need Help??


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

split has an optional LIMIT argument what you can try to utilize something like this:

perl -le '$s = "abcabdaaa"; $n = 3; print join( "i", split( /a/, $s, $ +n+1 ))'
See perldoc -f split for details.


Comment on Re: how to search and replace the match with specific number of times in a string
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-07-04 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls