better has asked for the wisdom of the Perl Monks concerning the following question:
Hello!
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?
Best
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looking for appropriate Regex
by james2vegas (Chaplain) on Apr 07, 2013 at 09:21 UTC | |
by better (Acolyte) on Apr 07, 2013 at 12:54 UTC | |
|
Re: Looking for appropriate Regex
by hdb (Monsignor) on Apr 07, 2013 at 09:56 UTC | |
by better (Acolyte) on Apr 07, 2013 at 13:32 UTC | |
|
Re: Looking for appropriate Regex
by Loops (Curate) on Apr 07, 2013 at 09:22 UTC | |
|
Re: Looking for appropriate Regex
by ww (Archbishop) on Apr 07, 2013 at 15:31 UTC | |
by better (Acolyte) on Apr 07, 2013 at 19:18 UTC | |
|
Re: Looking for appropriate Regex (Text::CSV)
by Anonymous Monk on Apr 07, 2013 at 09:22 UTC | |
by better (Acolyte) on Apr 07, 2013 at 13:12 UTC |