I want to match valid HTML comment only using regex.
I have seen many questions on stackoverflow but no one answer this.
Patterns allowed to match
<!-- some comments 1 -->
<!-- 1.91 -->
<!--
//-->
<!-- -->
But not these IE-only comments
<!--[if IE]> <![endif]-->
<!--[if !IE]><!--> <!--<![endif]-->
<!--[if IE 6]> <![endif]-->
What I think that it can be done by taking help of ‘[‘ if it is found as first character after <!-- it returns false.
any way you can give your own solution.
for php only to use preg_replace
I really don’t recommend you do this using regex, but if you insist, here is a basic regular expression: http://regex101.com/r/wI2kF7
With anchor tags: http://regex101.com/r/tC9xH4
Good luck.