Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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 romping around the Monastery: (5)
As of 2015-11-30 00:21 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (754 votes), past polls