Comment

Comment by coldtea

>Best practices are a very wide category, don't parse HTML with regular expressions is the kind of thing you really should just say don't do that.

I call BS.

"Don't have a continuously running service parse arbitrary HTML with regular expressions" would be a bad thing.

Parsing specific, given, HTML files, with known structure to the dev, with regular expressions (e.g. as part of a one-off scrapping script) is totally, absolutely, fine.

If my HTML file is like:

  <html>
  <body>
  <a href="xxxxx">foo</a><br>
  <a href="xxxxx">foo</a><br>
  <a href="xxxxx">foo</a><br>
  <a href="xxxxx">foo</a><br>
  <a href="xxxxx">foo</a><br>
  <a href="xxxxx">foo</a><br>
  <a href="xxxxx">foo</a><br>
  </body>
  </html>
I can parse it just fine with regex.

And even parsing is the wrong word: I can extract the information I want is a better term. I won't be parsing anything in the AST sense.

parent coldtea 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton