this post was submitted on 21 Sep 2024
300 points (96.3% liked)

Programmer Humor

32571 readers
259 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] communism@lemmy.ml 34 points 2 months ago (1 children)

OP isn't trying to parse HTML though.... they are trying to detect opening xml tags. Which seems quite achievable with regex.

[โ€“] winterayars@sh.itjust.works 1 points 2 months ago* (last edited 2 months ago)

It's still actually pretty sketchy, depending on exactly what you want to do. Strict regex still won't be able to match correctly if you want to match what an HTML parser considers the opening tag, though fancier regex will. If you're just looking for the tags in the HTML document as a flat document it's doable, though. (Mostly.)