This is truly one thing AI solved. Hard to write, easy to test. No one needs to learn this convoluted syntax in the future and we're all better for it.
How would you know if a regex is correct if you dont understand it?
Regex Isn't Hard (2023)
81–90 of 109 posts
Re: Regex Isn't Hard (2023)
#82Earlier quoted context omitted.
IMO it’s a “language” you need to understand in order to use. Just like you wouldn’t copy/paste any random snippet into your source code if you don’t understand exactly what it does. I see a lot of broken regex at work from people who use regular expressions but don’t understand them (for various reasons). It used to come with a “found this on stackoverflow”-excuse, but mostly now it’s “AI told me to use this” instea…
yeah programmers famously understands all the random boilerplate incantations they copy past in their code to get things going. totally definitively
Re: Regex Isn't Hard (2023)
#83Re: Regex Isn't Hard (2023)
#84I’m a fan of regular expressions, though I understand why many people wince at the sight. You should avoid showing them to a non-programmer who is interested in learning to code, because they’ll immediately fear programming is intractable. Even as much as I like regex, I wouldn’t recommend this post. One reason is the code style is too close to regular text: > a matches a single character, always lowercase a. That se…
I've also seen people use `[\s\S]` to match all characters when they couldn't use `.`.
Re: Regex Isn't Hard (2023)
#85I’m a fan of regular expressions, though I understand why many people wince at the sight. You should avoid showing them to a non-programmer who is interested in learning to code, because they’ll immediately fear programming is intractable. Even as much as I like regex, I wouldn’t recommend this post. One reason is the code style is too close to regular text: > a matches a single character, always lowercase a. That se…
I've also seen people use `[\s\S]` to match all characters when they couldn't use `.`.
Also you can use . with the dotAll /s
Re: Regex Isn't Hard (2023)
#86Re: Regex Isn't Hard (2023)
#87[flagged]
Re: Regex Isn't Hard (2023)
#88Earlier quoted context omitted.
How would you know if a regex is correct if you dont understand it?
You have test strings covering all cases and they match accordingly? The same way you'd know when writing manually.
Re: Regex Isn't Hard (2023)
#89https://jimbly.github.io/regex-crossword/
See also: Are Regex Crosswords NP-hard?
https://cs.stackexchange.com/questions/30143/are-regex-cross...
Re: Regex Isn't Hard (2023)
#90Earlier quoted context omitted.
My problem is that regexes are write-only, unreadable once written (to me anyway). And sometimes they do more than you intended. You maybe tested on a few inputs and declared it fit for purpose, but there might be more inputs upon which it has unintended effects. I don't mind simple, straight-forward regexes. But when they become more complex, I tend to prefer to write out the procedural code, even if it is (much) lo…
> I tend to prefer to write out the procedural code, even if it is (much) longer in terms of lines. This might work for you, but in general the amount of bugs is proportional to the amount of code. The regex engine is alredy throughly tested by someone else while a custom implementation in procedural code will probably have bugs and be a lot more work to maintain if the pattern changes.
I also prefer procedural code instead of regexes.