in reply to replacing continuesly occuring pattern
It's generally not considered a good idea to manipulate XML with regular expressions - dedicated XML parsing modules tend to do a better job.
That's said, here's one way to do it:
1 while $text =~ s{ <names?> ([^<]*) </names?> <name> ([^<]*) </name> }{<names>$1,$2</names>}gx;
This assumes that the 'name' tags cannot contain additional XML entities. It also isn't particularly efficient, but should be fine if your strings aren't longer than a few KB or so.
Hugo
|
|---|