Hacker News new | ask | show | jobs
by lowefk 1175 days ago
Reading regex is much easier than writing them when using visualization tools such as https://regexper.com/, https://regex101.com/, and https://jex.im/regulex/, especially for beginners. I always use them to read regex.
4 comments

Or you can use "verbose regex" which some languages implement like in Python (https://docs.python.org/3/library/re.html#re.X). The spaces are ignored and you can add comments on each line. I used this in the past and my coworkers were happy about it because they could understand the regex and even modify it.
> Or you can use "verbose regex"

How did I not know about this! Thank you very much. This solves my biggest gripe with regex.

> my coworkers were happy about it because they could understand the regex and even modify it.

The most important point. Computers might read code efficiently, but if people can't reason about it, that is a recipe for bugs to sneak in.

Using regexper changed my life. I’m not afraid of even the most complex regexes anymore.
For JS/TS, I’ll add https://github.com/compose-regexp/compose-regexp.js to that list.