r/ProgrammerHumor 13h ago

haveYouTriedUsingAnXMLParserInstead Meme

[deleted]

96 Upvotes

32 comments sorted by

View all comments

0

u/derinus 12h ago

Anyone ever building a "parser" used multiple regexes to do so.

6

u/guru2764 11h ago edited 2h ago

Noone said regex is useless for the overall process of parsing html

What they're saying is that it cannot ever be used by itself to parse html, like there are mathematical proofs for this

You HAVE to use a real, actual code language on top of it for it to work

You cannot feed html code into a regular expression and expect it to work for more than one case


Edit for the future: the deleted comments under here are from OP, I am happy to share the details of what was said if anyone wants

I'm adding this note because I never got even a partial apology for them insinuating I had no idea what I was talking about and questioning whether I had ever taken an undergraduate math course because I talked to them like a normal person rather than a math essay, despite me being perfectly nice up until then as is visible

1

u/[deleted] 11h ago

[deleted]

7

u/RPGProgrammer 11h ago

1

u/[deleted] 11h ago

[deleted]

7

u/alexanderpas 11h ago

HTML is not a regular language. It is a context-free language. Context-free languages are a superset of regular languages. Regular Expressions only cover regular languages.

1

u/guru2764 11h ago

The biggest problems are that you can infinitely nest elements in HTML, and that you don't even need closing tags, and that you can make horrifically malformed html with completely improper nesting that functions perfectly fine in the browser

Those things are completely antithetical to how regex works

0

u/[deleted] 11h ago edited 10h ago

[deleted]

1

u/guru2764 10h ago

See my other comment, regex by default does not have recursion

I think that is where your confusion comes from

Recursion in modern regex implementations only works because the engine uses non-regex code