A
A
Alexey Burlaka2018-03-17 11:12:16
Regular Expressions
Alexey Burlaka, 2018-03-17 11:12:16

How to cut tags correctly?

Friends, once again I ask for your help.
Can you tell me how to properly split nested tags? If the tag is "single-level", I got it right. But if nested, it doesn't work.
For example, we have this line:

<b> текст <i>вложение <br> </i> переход</b><b> текст <i>вложение <br> </i> переход</b><b> текст <i>вложение <br> </i> переход</b>

Task: in places where it occurs inside the tags <br>, you need to correctly “cut” the tags.
That is, you need to get the following from the source string ( br is correctly placed outside the tag boundaries ):
<b> текст <i>вложение </i></b>
<br><b><i></i> переход</b>

<b> текст <i>вложение </i></b>
<br><b><i></i> переход</b>

<b> текст <i>вложение </i></b>
<br><b><i></i> переход</b>

Tell me how to implement the task?
Sandbox: regex101
Thanks.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question