Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression: exclude html tags from "content"

One friend asked me this and as my knowledge on RegExp is not so good yet here I am.

How can exclude the HTML tags from this string?

re<br>na<br>to<br>galvao

I've tried some RegExp but it didn't work as I was expecting.

(.*)<.*>(.*)

But this RegExp gets the first < and the last >.

Any ideas?

like image 838
Renato Galvones Avatar asked Feb 13 '23 14:02

Renato Galvones


1 Answers

this is a quick way to do it:

var content = "re<br>na<br>to<br>galvao";
content = content.replace(/<[^>]*>/g,'');
like image 119
Crayon Violent Avatar answered Feb 16 '23 10:02

Crayon Violent