top | item 29253125

(no title)

nightbrawler | 4 years ago

  [0] Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
I love regular expressions and figuring out the syntax to solve problems I encounter where I can use regex. Such as searching code for calls with specific named params that may be in different order across the code base. But I always have this quote in the back of my mind if I'm thinking about using regex in code, especially areas that get hit a lot.

[0] https://blog.codinghorror.com/regular-expressions-now-you-ha...

discuss

order

laputan_machine|4 years ago

It's really subject-specific. What I usually see is a small problem easily solved by Regex, that a few months later down the line we need to expand the regex a little bit, but that's ok it's still readable... repeat this a bunch of times and now you have a critical regex line that nobody really understands how it works and nobody ever wants to touch without it being unit-tested to death.

It's just a riff on tech-debt, imho

Yajirobe|4 years ago

We need a natural-language <-> regex translator

TheCapn|4 years ago

I once asked my friend: "Is there anything Regex can't do?" He replied: "Work the first time?"

And that's how I always think of Regex now. It's an incredibly powerful tool that I pull out pretty often, but if I'm doing anything beyond the most basic pattern matching I know I'm about to lose a bit of time questioning my abilities and sanity.