Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Honestly, writing a regex is way easier than reading a regex, no? So it feels like now I have the harder task of proving that the generated regex is correct.


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.


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.


I consider myself a product designer so this is absolutely not true for me. Every time I try to write a Regex I have no idea how to even start. Copilot has been really good at starting me off and then I’ll take it to a regex site and understand it


I feel this is also true of code in general.

Writing is easy; reading is hard.

That's why LLMs aren't much help to me -- they just increase my workload by giving me more code to read and review. If I write it myself, I already know what it means, so that saves time and effort.


I find this mostly pays off in debugging: Having written code usually means I know it better than code I've reviewed, which I know better than code I've never seen. Finding a weird bug in code I know well is a _lot_ easier.


For me writing a regex is easy only if I remember the syntax, which I never do because they differ between languages and I only need them once a month or so.

For me the fastest way is to ask generator to create a valid and not necessarily correct regex, so that I can tweak it. I successfully used gpt for just that recently. It even got the capture groups right.


I agree. I similar arguments ("just write examples") a lot, and I really don't get that. Finding a comprehensive set of examples for code, regexps, shell, whatever is very, very hard.


This feels like a really cool idea for a tool - I would 100% use something that generates matching strings to a regex expression for checking my own or understanding other people's regex.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: