Answer the question
In order to leave comments, you need to log in
How to compose a regular expression to search for nested tags?
Hello! Please help me compose a recursive regular expression to search for tags.
I try to do this:
<([^>]+)>((?R)|.+)<\/\1>
I expect that this regular expression will search for paired tags <b></b>
, after which the content will be searched again, and if nothing is found, it will place the content in a separate group.
Testing on a line
<ul><li>1<span>qwe</span></li><div>sometext</div></ul><div></div>.
I can't figure out why it doesn't work. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question