←back to thread

Regex Isn't Hard (2023)

(timkellogg.me)
75 points asicsp | 1 comments | | HN request time: 0.224s | source
1. hyperman1 ◴[] No.43750625[source]
This is both a demo for the beauty and power of regexes, and of their dangers:

* The use of backslash separatores quickly makes a mess, as they tend to need escaping wherever regexes are usefull.

* The uppercase/lowercase is only right if there are no accented characters, so USA. This is bad in western europe in files where they are rare: Your program works for a while, then an accent sneaks in and breaks things.

* The exact meaning of all the specials like \( vs ( .

* Ranges work in most regex dialects but not everywhere.

* A simple regex for an int with a specific range is nasty. If you want a full float, good luck.

Regexes are great as initial filter or quick hack, but you need more in full size programs.

I'd love to see a better regex syntax, too.