Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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 studying the Monastery: (7)
As of 2015-05-26 08:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    In my home, the TV remote control is ...









    Results (495 votes), past polls