News for hackers. Stuff that matters.
Re:Show HN: Regex Cheatsheet by blauditore on Friday January 31, 2020 @09:41AM (#22201996)
Would be nice to have a regex for parsing HTML...

grabs popcorn

Re:Show HN: Regex Cheatsheet by bmn__ on Friday January 31, 2020 @10:15AM (#22202287)
Easy with a sufficiently powerful engine: https://stackoverflow.com/a/4234491

Relies on ?(DEFINE): http://p3rl.org/perlre#(DEFINE)

Re:Show HN: Regex Cheatsheet by quickthrower2 on Friday January 31, 2020 @02:16PM (#22204616)
There is a good comment on that answer:

> To sum up: RegEx's are misnamed. I think it's a shame, but it won't change. Compatible 'RegEx' engines are not allowed to reject non-regular languages. They therefore cannot be implemented correctly with only Finte State Machines. The powerful concepts around computational classes do not apply. Use of RegEx's does not ensure O(n) execution time. The advantages of RegEx's are terse syntax and the implied domain of character recognition. To me, this is a slow moving train wreck, impossible to look away, but with horrible consequences unfolding

Re:Show HN: Regex Cheatsheet by arkh on Friday January 31, 2020 @10:09AM (#22202223)
With subroutines and recursive patterns I think you could do something parsing valid HTML.

Your sanity won't be left intact tho.

Re:Show HN: Regex Cheatsheet by asicsp on Friday January 31, 2020 @10:25AM (#22202408)
how about this "match "A B C" where A+B=C"[1] for sanity?

[1] http://www.drregex.com/2018/11/how-to-match-b-c-where-abc-be...

Re:Show HN: Regex Cheatsheet by chirss on Friday January 31, 2020 @04:12PM (#22205795)
boom. https://regex101.com/r/PxSY4U/1 technically it does parse it. :P
Re:Show HN: Regex Cheatsheet by bmn__ on Saturday February 01, 2020 @11:05AM (#22211185)
Nope. <h1 class="foo>bar">My First Heading</h1> will misparse. (This is valid HTML 5.) You really need recursive regex or something equivalent in power, otherwise you will always fail.
Re:Show HN: Regex Cheatsheet by chirss on Wednesday February 12, 2020 @02:25PM (#22311874)
Well yea, it's a joke...
Re:Show HN: Regex Cheatsheet by geongeorgek on Friday January 31, 2020 @10:15AM (#22202280)
Haha..careful. someone might take this seriously