Hi,
I'm trying to replace all special characters (space, comma, parens) within double quotes in a string with an underscore using:
The following text
gets me
But only the last one is being substituted. How do I get to sub all the occurrences? Also, if there are two sets of double quotes (as in line 1) how do I process each set separately?
Thanks.
I'm trying to replace all special characters (space, comma, parens) within double quotes in a string with an underscore using:
Code:
while(<>) {
s/"(.*)[ ,:\]\[\(\)](.*)"/"$1_$2"/g;
print "$_\n";
}
Code:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<cleanup"a string,here with(junk">
<cleanup"a string,here[with junk">
<cleanup"a string)here:with,junk">
<cleanup"a string(here:with[junk">
<cleanup"a string,here:with)junk">
<cleanup"a string:here]with]junk">
</root>
Code:
<?xml version="1.0"_encoding="UTF-8"?>
<root>
<cleanup"a string,here with_junk">
<cleanup"a string,here[with_junk">
<cleanup"a string)here:with_junk">
<cleanup"a string(here:with_junk">
<cleanup"a string,here:with_junk">
<cleanup"a string:here]with_junk">
</root
Thanks.