I wanna to detect the the html tags in textarea or text input before submitting a form, it looks easy to do the detection "roughly" with regular expression /<\\/?[^>]*>/gi.test(str)
But if there are some normal content like " This clothes is not suitable for me since my height < 180cm and > 170cm ", the previous regExp will consider this content contains html tags coz there are <
and >
..
So, how to detect the html tags while supporting the normal greater-than and less-than sign?
Thanks.
Just Change the * in you Expression to a Plus: /<\\/?[^>]+>/gi
*
Means 0 or 1 of the pre Token +
Means 1 or more And a HTML tag always has at least one char in the tag.
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.