I have a similar problem to http://www.perlmonks.org/?node_id=647133 but can't get the \G solution to work. I have data coming in that has a variable number of data pairs, with pipe delimiting. It should be <name>foo</name><value>bar</value>
The current feed comes in as:
so I am transforming this via:<name>test</name><value>431|alpha|123|bravo|542|charlie|412</value>
which gives me the correct output ofperl -pe "do{s/(\<value\>.+?)\|(.+?)\|(.*?)(?=\<\/value\>)/$1\<\/value +\>\<name\>$2\<\/name\>\<value\>$3/gi;} while /\|/;"
When I try to recode using Oha's solution with \G, it seems to only process the line once<name>test</name><value>431</value><name>alpha</name><value>123</value +><name>bravo</name><value>542</value><name>charlie</name><value>412</ +value>
perl -pe "s/(\<value\>|\G)(.+?)\|(.+?)\|(.*?)(?=\<\/value\>)/$1$2\<\/v +alue\>\<name\>$3\<\/name\>\<value\>$4/g" <name>test</name><value>431</value><name>alpha</name><value>123|bravo| +542|charlie|412</value>
What am I doing wrong here?
In reply to Recursive substitution difficulties by wx27
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |