Re:Is there a regular expression to detect a valid regular e...
by unlinkr on Sunday September 08, 2019 @12:09PM
(#20911365)
That is not XHTML.
[ Parent
| on HN ]
Re:Is there a regular expression to detect a valid regular e...
by hk__2 on Sunday September 08, 2019 @03:05PM
(#20912658)
What about <a>this <!-- </a> --> </a> <!-- </a> -->?
Re:Is there a regular expression to detect a valid regular e...
by unlinkr on Monday September 09, 2019 @01:56AM
(#20915540)
Yes you can tokenize this with a regular expression and extract the valid start and end tags.
If comments in XHTML could nest you would have a problem. But this is not the case.
Re:Is there a regular expression to detect a valid regular e...
by hk__2 on Monday September 09, 2019 @03:53AM
(#20916055)
> Yes you can tokenize this with a regular expression and extract the valid start and end tags.
So you need more than a regular expression, hence your premise is incorrect.
Re:Is there a regular expression to detect a valid regular e...
by unlinkr on Monday September 09, 2019 @04:52AM
(#20916334)
No, you don't need more than a regular expression. If you want to extract elements, i.e. match start tags to the corresponding end tags, then you need a stack-based parser. But just to extract the start tags (which is the question) a regular expression is sufficient.
The original question is a question about tokenization, not parsing, which is why a regular expression is sufficient.
Re:Is there a regular expression to detect a valid regular e...
by nurettin on Sunday September 08, 2019 @12:26PM
(#20911487)
<input value="how about this? />"/>
Re:Is there a regular expression to detect a valid regular e...
by unlinkr on Sunday September 08, 2019 @01:15PM
(#20911821)
That is a valid XHTML tag (if I remember correctly) and can be matched perfectly fine by a regex.
Re:Is there a regular expression to detect a valid regular e...
by nurettin on Sunday September 08, 2019 @01:55PM
(#20912108)
Perhaps something like "([^"]*)" could skip what is inside the string literal. Unless there is "<input" in the string literal, then where you start parsing becomes very important.
Re:Is there a regular expression to detect a valid regular e...
by unlinkr on Monday September 09, 2019 @04:58AM
(#20916371)
That pattern would indeed match a quoted string. I don't see how it would matter if the quoted string contains something like "<input". It can contain anything except a quote character.
Re:Is there a regular expression to detect a valid regular e...
by nurettin on Monday September 09, 2019 @08:34AM
(#20917502)
It just makes the starting offset of the regex input important.