HTML Comment
beginnerMatches HTML comments including multi-line content.
htmlcommentparsing
Pattern
/<!--[\s\S]*?-->/gTry It
0 of 6 strings matched
Explanation
Matches HTML comments from <!-- to the next -->. Uses [\s\S]*? (non-greedy any character including newlines) to capture multi-line comments.
Test Strings
Matching
- <!-- comment -->
- <!-- multi line comment -->
- <!-- TODO: fix this -->
Non-matching
- // comment
- /* comment */
- <! not a comment >
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /<!--[\s\S]*?-->/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);