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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://820349]
help
Chatterbox?
[atcroft]: .oO(Then there is the effect if a site changes their timezone, such as when the International Date Line was moved by the purchase of Alaska by the US from Russia in 1867, or several places (I cannot recall off-hand) that moved from one side of the Date
[atcroft]: Line to the other recently....)
[atcroft]: .oO(Then again, you also have to be careful if you had it to the database, and be aware of any assumptions it makes (such as SQLite assuming Gregorian calendar and a day of exactly 86400 seconds)...)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2017-04-29 04:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.