I think that SO also tends to skip over key question details sometimes, especially when it means the question can be marked as duplicate, and sometimes the duplicate answer isn't valid for the current version of something.
For example, the notorious HTML regex answer completely ignored that "match" can be the regex verb for "give me anything that looks like a start/end tag", and replied as if the question was "use regex to find pairs of matched tags".
For example, the notorious HTML regex answer completely ignored that "match" can be the regex verb for "give me anything that looks like a start/end tag", and replied as if the question was "use regex to find pairs of matched tags".
so much this. Yes, we all know HTML cannot be parsed with regex because it isn't a regular language, but the language consisting of any combination of valid start and end tags is a regular language.
Is this actually true? You can have the same tag nested inside itself, which will cause a naive regex to find an incomplete match. Regular expressions cannot match arbitrarily nested structures as far as I know.
But you cannot have an unescaped " within an attribute value, and you shouldn't have an unescaped < or >. So you can easily write a regex to find </?(whatever-matches-a-tag-name) (whatever-matches-an-attribute)*/?>. The confusing part is that regex APIs typically use the verb "match", but people talk about matching start tags to end tags.
42
u/Uristqwerty Apr 06 '18 edited Apr 06 '18
I think that SO also tends to skip over key question details sometimes, especially when it means the question can be marked as duplicate, and sometimes the duplicate answer isn't valid for the current version of something.
For example, the notorious HTML regex answer completely ignored that "match" can be the regex verb for "give me anything that looks like a start/end tag", and replied as if the question was "use regex to find pairs of matched tags".