in reply to Looking for appropriate Regex

Try this.

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

Replies are listed 'Best First'.
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ą!