diff --git a/test/test_parsing.py b/test/test_parsing.py
index 0e006298f7..9641df91df 100644
--- a/test/test_parsing.py
+++ b/test/test_parsing.py
@@ -343,7 +343,7 @@ class TestParsing(unittest.TestCase):
-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------
this is a leftover comment --> and end
+ here is and end
----------------^^^^^^^^^^^----------------^^^^^^^^^^^^^^^^^---------
--------^^^^^^^^^^^^^-----------------------------^^^^^^^^^^---------
diff --git a/yt_dlp/parsing.py b/yt_dlp/parsing.py
index f4aaf1ac4f..72d7e448bd 100644
--- a/yt_dlp/parsing.py
+++ b/yt_dlp/parsing.py
@@ -20,7 +20,7 @@ class HTMLIgnoreRanges:
if offset in ranges:
...
"""
- REGEX = re.compile(r'|?\s*(?:script|style)\b[^>]*>', flags=re.IGNORECASE)
+ REGEX = re.compile(r'':
+ if match_string.startswith('') or match_string in ('-->', '--!>'):
return offset < self._last_match.start()
return offset >= self._last_match.end()