I’d like to know the possible Regex suitable for checking a string that includes certain HTML tags, namely, <b>, <i> and <a> or it has no any tags. using PHP preg_match.
For example:
"This a text only.." return true
"This is a <b>bold</b> text" return true
"this is <script>alert('hi')</script>" return false
"this is <a href="#">some</a>and <h1>header</h1>" return false
Try using
strip_tags()instead. Regular expressions aren’t suited for parsing HTML tags.