There are a number of ways to craft a regular expression to do this. One is to use look-behind and look-ahead assertions. These make sure the characters surrounding the space character match, but will leave them alone and not include them in the text to be replaced:
$id =~ s/(?<=[a-z]) (?=[a-z])/,/;
However, the results of any regex are likely to be spotty. If instead you use a module like Text::CSV to parse your csv files, you should be able to receive your data clean with all commas intact
In reply to Re: Looking for appropriate Regex
by Loops
in thread Looking for appropriate Regex
by better
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |