Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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 lurking in the Monastery: (6)
As of 2014-12-28 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls