5 ms·
Does the proposed regular expression really handle embedded script content correctly? From my limited understanding of HTML, pretty much only </script> counts a
by adament 5y ago
Does the proposed regular expression really handle embedded script content correctly? From my limited understanding of HTML, pretty much only </script> counts as closing the script contents and everything else is treated as part of the script.
- goto11 5y agoThe question is about XHTML though, not HTML which have a more complex syntax.
- jontro 5y agoTo me it’s a bit ambiguous if the original question is about both html and xhtml. It’s tagged with both
- goto11 5y agoThe headline says XHTML. HTML does not even have the self-closing tags the question is concerned about.
- jameshart 5y agoThe headline said that the author was specifically looking to avoid 'xhtml self-contained tags', but that doesn't mean they could assume the document they were looking in was valid XHTML - just that it might contain XHTML-style 'self-closing' tags. I've seen plenty of plain HTML files that aren't well-formed XML yet contain <br/> tags.
- goto11 5y agoYeah the trailing slash in <br /> is legal in HTML, but it doesn't actually make the tag self-closing. For example <b /> is still an opening tag which require a </b>.
- megous 5y agoDoes it matter? You can create regex with lookahead for </script>. The point is that it's possible to solve the problem from SO this way, due to the nature of the problem, not that this particular expression is perfectly correct.
- anaerobicover 5y agoIt seems the article does defend "it's possible" for strictly regular expressions. To allow lookahead will be context-sensitive, so not in that spirit.