A few thought about snarky answers on StackOverflow (2019)
5 hours ago
- #Regular Expressions
- #Misinformation
- #Parsing
- Regular expressions can identify individual syntax units in XHTML such as comments, start tags, and end tags, but they cannot match start tags to end tags arbitrarily due to lack of recursion.
- A common misunderstanding is that HTML is a Type 2 grammar and regex is Type 3, making matching impossible, but regex can be used with a counter or stack for parsing to handle nesting.
- Parsing involves tokenization with regex and building a tree structure, but standard parsers like DOM do not expose distinctions like empty elements vs. self-closing tags, limiting solutions to the original problem.
- StackOverflow's voting system sometimes promotes memes and misinformation, as seen in the snarky answers about regex and XHTML, overshadowing legitimate solutions.