Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Replacing matches within string without splitting.

by BrowserUk (Pope)
on Jan 02, 2013 at 06:44 UTC ( #1011213=note: print w/ replies, xml ) Need Help??

in reply to Replacing matches within string without splitting.

Use lookahead:

$t = "1,2,3,4\n8,9,10,11\n7,8,9,10,\n12,13,14,15\n";; print $t;; 1,2,3,4 8,9,10,11 7,8,9,10, 12,13,14,15 $t =~ s[(\D|^)(?=\d(?:\D|$))][${1}0]g;; print $t;; 01,02,03,04 08,09,10,11 07,08,09,10, 12,13,14,15

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Comment on Re: Replacing matches within string without splitting.
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2015-10-04 21:49 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (105 votes), past polls