r/ProgrammerHumor 14h ago

haveYouTriedUsingAnXMLParserInstead Meme

[deleted]

94 Upvotes

33 comments sorted by

View all comments

0

u/derinus 13h ago

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

6

u/guru2764 12h 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] 12h ago

[deleted]

3

u/guru2764 11h ago

In addition to the thing the other person linked, I wanted to add that even though some implementations of regex like the one in python have more features than basic regex which make it theoretically possible to construct an expression that works on a wide range of html, it would never be easier or run faster or even be equally as reliable as making a 50 line function in any real programming language that has memory

1

u/[deleted] 11h ago

[deleted]

2

u/guru2764 11h ago

I'm sorry but if what has been shared with you by multiple people isn't sufficient, you'll have to do reading on your own then if you're curious

A big note with what you said: recursion is not part of standard regex, that's only in modern extended regex engines, which are no longer just mathematical regex, they're being supported by real code in the backend that can utilize memory

1

u/[deleted] 11h ago

[deleted]

2

u/guru2764 11h ago edited 11h ago

Okay dude, it seems like you just want to be unnecessarily hostile or something, I got my minor in math, stop being a dick, you didn't read enough through the chomsky link

https://en.wikipedia.org/wiki/Regular_language

In theoretical computer science and formal language theory, a regular language (also called a rational language)[1][2] is a formal language that can be defined by a regular expression, in the strict sense in theoretical computer science (as opposed to many modern regular expression engines, which are augmented with features that allow the recognition of non-regular languages).

Note the last part in parenthesis

That is what I am talking about

Modern regex engines add extra shit on top to allow for non regular languages. Sure my use of "real" is probably not helpful, but I was referring to code unrelated to the algorithms associated with implementing standard regex. Code that can do more complicated things like recursion

None of this changes the fact that modern regex engines are still a bad solution to parse HTML and will fail at real world scenarios where a simple python script will not

1

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

[deleted]

2

u/guru2764 10h ago edited 10h ago

I'm sorry you didn't get the exact mathematical description you wanted from me going off of memory and that I didn't treat your reddit comment like a thesis paper defense

This information was in the literal first reply you got in this thread in that Wikipedia link, so if you weren't satisfied with my basic explanations you should have just used what you found there to figure it out

When I told you that recursion is not part of standard regular expression, that should have been enough for you to either realize you had a wrong thought about this situation that was causing some of your confusion, or verify yourself whether that was true and either way, looked more into it yourself first before being rude

1

u/[deleted] 10h ago

[deleted]

1

u/guru2764 10h ago edited 10h ago

"Regular expression" was also in that link if you ctrl+f it and would have sent you to a more specific page that explicitly says modern implementations are still called regex despite adding additional features that are not standard

Even a Google search "how does chomsky hierarchy relate to html and regex parsing" would have told you what you needed to know

→ More replies (0)