foo,bar,baz,"foo, bar, baz",blah,"widgets, or so"
How can I replace all commas (for the sake of this example, with #) to generate this string:
foo#bar#baz#"foo, bar, baz"#blah#"widgets, or so"
$myString =~ s/,/#/ig;
$myString =~ s/((?<=\")[^\"]+)#([^\"]+(?=\"))/$1,$2/ig;
That works great, except the fact that the last regexp only replaces the last occurance between the quotes. So, for the string above, I have to run it twice. If there are more commas, I have to run it more...
Anything I can do to get away from that?