4 ms·
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.
by ar9av 4y ago
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.
- qsort 4y agoI 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.
- lowefk 4y agoReading regex is much easier than writing them when using visualization tools such as https://regexper.com/ https://regexper.com/, https://regex101.com/ https://regex101.com/, and https://jex.im/regulex/ https://jex.im/regulex/, especially for beginners. I always use them to read regex.
- pygy_ 4y agoFor JS/TS, I’ll add https://github.com/compose-regexp/compose-regexp.js https://github.com/compose-regexp/compose-regexp.js to that list.
- qrio2 4y agohttps://www.debuggex.com/ https://www.debuggex.com/ is my favorite
- Arbortheus 4y agoUsing regexper changed my life. I’m not afraid of even the most complex regexes anymore.
- JTyQZSnP3cQGa8B 4y agoOr you can use "verbose regex" which some languages implement like in Python (https://docs.python.org/3/library/re.html#re.X 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.
- krisoft 4y ago> 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.
- foobarbecue 4y agoI 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.
- fhd2 4y agoI 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.
- yawnxyz 4y agoI 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
- kuboble 4y agoFor 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.
- benrutter 4y agoThis 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.