'Don't parse markup languages with Regex' is an annoying trollpost and it should die... right?
TehPers @ TehPers @beehaw.org Posts 0Comments 683Joined 2 yr. ago
TehPers @ TehPers @beehaw.org
Posts
0
Comments
683
Joined
2 yr. ago
This advice mostly applies to people who are less experienced and less familiar with just how complex HTML can be. As for other languages - if you're doing regex on markdown, you'll probably be fine (but you should verify if you're writing something for the general case that must not fail). But in HTML's case:
img
andlink
end in/>
, butdiv
must end in a separate closing tag)If you're trying to use Regex to parse a specific website's HTML, you'll be able to get what you want eventually, but as a general HTML parser, there will always be some website that breaks your assumptions.