Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Looking for appropriate Regex

by hdb (Parson)
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 about the Monastery: (5)
As of 2014-07-31 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (244 votes), past polls