Find everything between two XML tags with RegEx

前端 未结 5 1398
无人及你
无人及你 2020-11-27 13:02

In RegEx, I want to find the tag and everything between two XML tags, like the following:


    

        
5条回答
  •  情书的邮戳
    2020-11-27 13:44

    this can capture most outermost layer pair of tags, even with attribute in side or without end tags

    ().)*-->|<\w*((?!\/<).)*\/>|<(?\w+)[^>]*>(?>[^<]|(?R))*<\/\k\s*>)
    

    edit: as mentioned in comment above, regex is always not enough to parse xml, trying to modify the regex to fit more situation only makes it longer but still useless

提交回复
热议问题