Hi, I have the need to convert a xml tag that contains comma separated entries into multiple tags. This is mixed into a larger XML file and the pattern may occur multiple times on the same line or on different lines.
For example: Replace <tags>one, two, three, four</tags> with: <tags> <tag>one</tag> <tag>two</tag> <tag>three</tag> <tag>four</tag> </tags> There won't always be four entries. In fact there could be zero. Here's what I did, which works good enough: %s/<tags>\(\_[^<]\+\)<\/tags>/\=substitute(submatch(0), ",\s\*", "<\/ tags>\r<tags>", "g")/g My question is: Is there another, non-vim specific way to reference the repeating group of comma separated values. What I wanted to do was something like this: %s/<tags>\(\([^,]\+\),\s*\)\+</tags>/<tag>\1<\tag>/g But \1 will only refer to the first time it hits the pattern, not the subsequent one. The basic task is to find the content between the <tags> tags and replace the comma separated entries with tag delineated entries. Ideally using "standard" regex notation that might work in vim, perl, and sed so I could script it. I tried googling for this, but I don't know what to google for. Searching fore regex, repeating group, etc gives back other examples. Thanks, Don However --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---