Raeef
Raeef

Reputation: 13

Select all text but HTML Tags

Been trying to figure this out for a while, came across this (<[^>]*>) which helped me select all html tags, my objective is to use regex to help me select anything but HTML tags.. i tried to negate this but couldnt figure it out..

Apprecaite your help

here's an example, so in summary i would like to select all but html tags..

<br>
<font size="2" face="Arial">&nbsp Bla Bla Bla</font>
<br>
<font size="2" face="Arial">More Bla Bla Bla</font> <br>
<br>Some more bla bla bla<br>
<br>

Upvotes: 0

Views: 188

Answers (1)

TobiasR.
TobiasR.

Reputation: 801

Following should work

(?<=>)[^<>]+(?=<)

or if you only want text between opening and closing tags

 (?<=>)[^<>]+(?=(<\/))

but the second one fails at <br>Some more bla bla bla<br>

"<" and ">" inside your string will screw almost every regex up.

You should use a Dom-Parser instead of Regex

Upvotes: 1

Related Questions