Regular Expressions 101

Community Patterns

TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ

1

Regular Expression
Python

r"
<!DOCTYPE html>|</?\s*[a-z-][^>]*\s*>|(\&(?:[\w\d]+|#\d+|#x[a-f\d]+);|<!--[\s\S\n]*?-->)
"
g

Description

This would appear to violate the premise of this famous StackOverflow answer, however this is not parsing as such, only matching or heuristic identification.

Technically, all text is HTML if served to a browser in such a way that the browser chooses to interpret it that way, e.g. using a text/html Content-Type.

Submitted by Alice Bevan-mcgregor - 10 months ago