News for hackers. Stuff that matters.
Re:Is there a regular expression to detect a valid regular e... by lolinder on Sunday September 08, 2019 @09:03AM (#20910319)
My favorite part of it is the moderators' note at the end:

> Moderator's Note

> This post is locked to prevent inappropriate edits to its content. The post looks exactly as it is supposed to look - there are no problems with its content. Please do not flag it for our attention.

Re:Is there a regular expression to detect a valid regular e... by gnud on Sunday September 08, 2019 @10:41AM (#20910842)
The big problem with the content is suggesting to use an XML parser to parse HTML. That might often work, and several XML parsers have some sort of HTML "mode", but in general, no, not really. HTML documents are frequently invalid XML. HTML documents lack an XML declaration, they don't close all tags, etc. They might even lack a root element. Someone mentioned this in a comment on SO, but it was (as far as I could see) not really addressed or answered.

HTML 5 has it's own parsing rules, specified at [1]. However, I don't know of any implementation of these outside of browsers. I normally use Beatuiful Soup [2] (for Python) or HTML Agility Pack [3] (for .NET), and while I don't think these implement the exact standard, they're easier than struggling with a XML parser for HTML "in the wild".

1: https://html.spec.whatwg.org/multipage/parsing.html 2: https://www.crummy.com/software/BeautifulSoup/ 3: https://html-agility-pack.net/

Re:Is there a regular expression to detect a valid regular e... by kortex on Sunday September 08, 2019 @11:10AM (#20910991)
The question title implies he's parsing XHTML text.

> XHTML is an XML-based HTML. It serves the same function as HTML, but with the same rules as XML documents.

https://stackoverflow.com/q/1429065

Re:Is there a regular expression to detect a valid regular e... by ChrisSD on Sunday September 08, 2019 @01:03PM (#20911719)
The question title is ambiguous but the question tags include both HTML and XHTML. Self-closing `<element />` is an XML-ism which in HTML is treated the same as `<element>` but it was still fashionable to use them in HTML when XHTML was at its height.