3 ms·
Don't HTML parsers use regexes for their lexical scan phase?
by cia_plant 17y ago
Don't HTML parsers use regexes for their lexical scan phase?
- statictype 17y agoI suppose that depends entirely on how the parser was implemented. You could write a scanner that doesn't use regexes. It could just read in characters one at a time and hard-code the logic for matching tokens. On the other hand, I wouldn't be surprised if many of the standard html parsing libraries use regex libraries internally to match tokens. If you used a scanner generator like lex, you would specify your scanner using regexes and lex would generate code that expands those regexes into an automata. I guess that also counts as using regexes, only they're compiled down at compile-time instead of at runtime.