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.
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.
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/