Matching between comments
|
|
What would be the best way of matching everything between two comments and replacing it with a line of html? So, <!-- comment -->
would become <!-- comment -->
|
|
|
I've been trying to do this to remove some incredibly annoying sigs. They are surrounded by comments like shown above. Could someone help me with the regular expression for selecting between two comments? It works when I test it here (http://www.regular-expressions.info/javascripte...) but not in my GreaseMonkey script.
var expression = new RegExp("<!-- sig -->.*<!-- / sig -->", "g");
var replacement = "<br/><br/><p>__________(sig removed)__________</p>";
document.body.innerHTML = document.body.innerHTML.replace(expression, replacement);
|
|
|
To answer my own question, the regex should be: "<!-- sig -->((.|\n)*?)<!-- / sig -->" |
