3 ms·
I reckon that technically regex is a tool that can be used to parse HTML. It's just that you could only use it in a very trivial way that would be better suited
by mistercow 14y ago
I reckon that technically regex is a tool that can be used to parse HTML. It's just that you could only use it in a very trivial way that would be better suited to other tools.
- charliesome 14y agoRuby regular expressions have a \g operator which lets you call a sub expression - so technically they could be used to parse HTML if you're a masochist.
- pjscott 14y agoPropriety requires that someone point out that any "regular expression" permitting recursion is not, in fact, a regular expression in the formal sense. Luckily for anybody wanting to do it anyway, parsing expression grammars can handle that sort of thing with theoretical aplomb: http://en.wikipedia.org/wiki/Parsing_expression_grammar http://en.wikipedia.org/wiki/Parsing_expression_grammar
- michaelhoffman 14y agoNo. Technically, you cannot parse HTML with regular expressions. You can find certain strings in HTML which is a different thing.
- mistercow 14y agoAt the very least, you can use regex to match individual characters as you scan the HTML for parsing. It's an inefficient and stupid way to do it, but it is still something you can do. And in that case, regex is technically a tool that you are using to parse HTML, even though 99.9% of the work is being done by non-regex code.