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?
this is a quick way to do it:
var content = "re<br>na<br>to<br>galvao";
content = content.replace(/<[^>]*>/g,'');
Match all html tags with this regex:
<("[^"]*?"|'[^']*?'|[^'">])*>
see demo here: http://regex101.com/r/fA0oT4
You could use a non-greedy match. According to the answer to this question , in javascript it is *?
So, assuming this is the only problem with your regex, it should work with
(.*?)<.*?>(.*?)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.