Dirk Schiller
Dirk Schiller

Reputation: 534

Regex - Find Tag with linebreak

How to find the <span>LINEBREAK</span> Tags in the middle ( the second opening and closing span Tags ) ?

<span>
Some Text
</span>
<span>

</span>
<span>
Some other Text
</span>

If is use <span> I can find the opening Tag. If I use <\/span> I can find the closing Tag. If i use ^\s*$ I can find the Linebreak. But how can I combine all three ?

<span>^\s*$<\/span> doesn't work.

I also tried <span>\n^\s*$\n<\/span> and <span>\r\n^\s*$\r\n<\/span>.

Upvotes: 0

Views: 49

Answers (2)

mauriciodelos
mauriciodelos

Reputation: 26

you can try this <span>.*?\r\n^$\r\n.*?</span>

This will search for new empty lines inside <span> tags

Upvotes: 0

Red
Red

Reputation: 7324

Try the code below. This will match any span with a linebreak in it.

<span>(\r\n|\r|\n)</span>

If above code isn't working try this. This will find any span with zero to unlimited newlines.

<span>(\n)*</span>

Upvotes: 1

Related Questions