better has asked for the wisdom of the Perl Monks concerning the following question:


I am looking for an appropriate regular expression.

After parsing a csv file, commas are missing within the strings:

A B 1234 a,b -> A B 1234 a b

A B 1234 c,e -> A B 1234 c e

Not knowing how to avoid the problem in the first place, I thought to fix the problem afterwards. I tried to define a regex, which should find matches within the parsed strings and to substitute them like this:

$id =~ s/[a-z] [a-z]/[a-z],[a-z]/;

But this doesn't work!

Has anybody any idea how to solve this problem?