开发者

Aggregate regex replace

So this is purely a question of curiosity...

Say I have a set of tags:

<tag>
  <sub>A</sub>
  <sub>B</sub>
  <sub>C</sub>
</tag>
<tag>
  <sub>1</sub>
  <sub>2</sub>
  <sub>3</sub>
</tag>

Is it possible to, in a single Regex.Replace command, aggregate the contents of all <sub> tags within a <tag> into one <sub>.

Like so:

<tag><sub>ABC</sub></tag>
<tag开发者_如何学Go><sub>123</sub></tag>

My guess is no, but I figured I'd give it a shot.


Is the theoretical tag set always this clean? If so, replacing </sub>\s+<sub> with nothing would do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜