News for hackers. Stuff that matters.
Re:You Cannot Parse HTML with Regular Expressions by util on Sunday April 18, 2010 @11:44AM (#1274967)
Is it right that BeautifulSoup was (is?) implemented in terms of Python regular expressions?
Re:You Cannot Parse HTML with Regular Expressions by rbonvall on Sunday April 18, 2010 @02:07PM (#1275182)
Regular expressions can be (and are) used to tokenize the code, but cannot do the actual parsing.

What "REs can't parse HTML" means in theory is that you cannot design a regexp that tells HTML apart from non-HTML.

The fundamental reason is that regexps cannot detect arbitrarily-deep nested structures.

In practice it is possible, because most regexp engines are Turing complete, but it would be crazy to do so.