Live data from Hacker News

Preventing line breaks in elements

alexwlchan.net

21–23 of 23 posts

Re: Preventing line breaks in <code> elements

#22
post #8
post #2

You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML.

You can absolutely parse HTML with regex, so long as the document is finite in length. Every finite language is regular, hence can be parsed with regex's.

and you write your regex specifically for that document length, handling all possible nesting combinations. combinatoric explosion

Re: Preventing line breaks in <code> elements

#23
post #7
post #2

You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML.

What do you mean you can't. I do it all the time

As the saying goes: you can fool all people some of the time, and some people all of the time.

Actually, depending on what you're doing, it can be totally fine. Just be aware that you're losing some generality.

Post reply on HN