Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 musing on the Monastery: (12)
As of 2015-08-03 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (45 votes), past polls