Matching nested structures

Back to list2026-06-10
You

My regex for nested brackets keeps failing.

ChatGPT

Because regular expressions cannot count. Nesting needs a parser, even a ten line one with a stack. The regex that appears to work handles two levels and fails on the third, which is worse than not working at all.

You

Any downside worth knowing before I commit?

ChatGPT

It commits you to a format that is tedious to migrate away from later. The first weeks also look worse than doing nothing, which is when most people abandon it.