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

Re: Looking for appropriate Regex

by hdb (Prior)
on Apr 07, 2013 at 09:56 UTC ( #1027346=note: print w/ replies, xml ) Need Help??


in reply to Looking for appropriate Regex

Try this.

$id =~ s/([a-z]) ([a-z])/$1,$2/;


Comment on Re: Looking for appropriate Regex
Download Code
Re^2: Looking for appropriate Regex
by better (Acolyte) on Apr 07, 2013 at 13:32 UTC

    Marvellous!

    Thanks a lot!

    It works!

    But,oops, I found a few exceptions, like: A B 1234 a c d

    I tried to fix this by simply extending your script:

    $id =~ s/([a-z]) ([a-z]) ([a-z])/$1,$2,$3/;

    But this doesn't work!

    better

    Oh yes, it does!

    I just swaped both lines, so that the extended line preceeds your line. And voilą!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
As of 2015-07-03 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls