News for hackers. Stuff that matters.
Re:You can't parse XML with regex. Let's do it anyways by RHSeeger on Sunday October 05, 2025 @12:21AM (#45478819)
That's not entirely fair. It's relatively easy to learn the basics of regular expressions. But it's also relatively easy, with that knowledge, to write regular expressions that

- don't work the way you want them to (miss edge cases, etc)

- fail catastrophically (ie, catastrophic backtracking, etc) which can lead to vulnerabilities

- are hard to read/maintain

I love regular expressions, but they're very easy to use poorly.

Re:You can't parse XML with regex. Let's do it anyways by 8n4vidtmkvmk on Sunday October 05, 2025 @03:49AM (#45479693)
If they don't work the way you want, you just keep refining it. This is easy if you actually test your regex in real data.

Fail catastrophically.. I had that happen once on an unexpectedly large input. That was a fun lesson. Ironically, the solution was to (*FAIL)

In any case, I learned a lot and delegating that to an LLM and learning nothing would not have put me in a better position.

Re:You can't parse XML with regex. Let's do it anyways by RHSeeger on Monday October 06, 2025 @11:20PM (#45499076)
> If they don't work the way you want, you just keep refining it. This is easy if you actually test your regex in real data.

There can be edge cases in both your data and in the regular expression itself. It's not as easy as "write your code correctly and test it". Although that's true of programming in general, regular expressions tend to add an extra "layer" to it.

I don't know if you meant it to be that way, but your comment sounds a lot like "it's easy to program without bugs if you test your code". It's pretty much a given that that's not the case.

Re:You can't parse XML with regex. Let's do it anyways by phatskat on Wednesday October 08, 2025 @01:48AM (#45512517)
I didn’t get the “it’s easy to program without bugs” vibe at all, and OP even mentioned an edge case that took their parser down (BUG!)

Neither the human nor the AI will catch every edge case, especially if the data can be irregular. I think the point they were making is more along the lines of “when you do it yourself, you can understand and refine and fix it more easily.”

If an LLM had done my regular expressions early in my career, I’d have only !maybe! have learned just what I saw and needed to know. I’m almost certain the first time I saw (?:…) I’d have given up and leaned into the AI heavily.

Re:You can't parse XML with regex. Let's do it anyways by superb_dev on Sunday October 05, 2025 @12:59AM (#45478960)
Using the AI to write them for you is going to lead to the same problems but worse because you don’t have the knowledge to do anything about it