Reputation: 1625
I've got the following regex
^[\<\!\-\-]\w+?\W?[\-\-\>]$
It is supposed to check the start of a string for <!--
and end of a string for -->
with any number of characters in between, including all punctuation and can occur more than once in a string.
for example <!--something here? or even this!. -->
would return true
and also <!--some--><!--thing-->
would return true
I also want to create another regex that will replace the <!--
and -->
with a blank string.
The regex doesn't seem to work. How can i fix it?
Upvotes: 0
Views: 321
Reputation: 35198
You use of a character []
with [\<\!\-\-]
doesn't make any sense.
To match for that string, all you need is <!--.*?-->
If you want it bounded to the whole string, then yes, you can add the ^
and $
to produce: ^<!--.*?-->$
.
Upvotes: 2