Re:Oh Yes You Can Use Regexes to Parse HTML
by adobriyan on Friday July 08, 2011 @08:35AM
(#2742170)
Backreferences in some sense don't work because real HTML contains misnesteded tags and other bugs, so many of them, even HTML5 spec explictely mentions correction algo.
Re:Oh Yes You Can Use Regexes to Parse HTML
by FaceKicker on Friday July 08, 2011 @11:52AM
(#2742936)
Why is the language matched by /(.)\1/ non-regular? Isn't it finite (aa, bb, cc, dd, ..., zz if your alphabet is the lowercase letters a-z)? And all finite languages are trivially regular.
Maybe he meant /(.*)\1/?
Note: I know that backreferences make Perl regexes capable of matching non-regular languages, but this doesn't seem like an example of that.
From the comments:
Q. "The answer is you can't. HTML is not regular so be definition it can't be described by a regular expression."
A. "Your use of REGULAR in regular expressions has been irrelevant and wrong since Ken Thompson first put backrefs into regexes around 40 years ago. /(.)\1/ parses non-REGULAR languages perfectly well. Please stop repeating this nonsense. – tchrist"