3 ms·
> (and why complex regexes will inevitably hurt you) This is a needless bash on Regex (which is not even mentioned in the article at all, except as a YAML foot
by lectrick 12y ago
> (and why complex regexes will inevitably hurt you)
This is a needless bash on Regex (which is not even mentioned in the article at all, except as a YAML footnote!). I have a tip, though- If you DO need to write a complex regex (hint: it will run much faster than doing the same thing in code), document it using things like the /x switch! Here is an example I wrote of a complex password validator- I don't think most developers would have a problem understanding what's going on:
https://gist.github.com/pmarreck/4c5f1076498da1a86062 https://gist.github.com/pmarreck/4c5f1076498da1a86062
- lylo 12y agoI agree in hindsight it's an overly provocative title. If I could change it I would (I have changed the actual blog post title FWIW). Sorry if it offended you or regular expressions in general.
- lectrick 12y agoHey, I get that regexes can be a bit "dense" to understand. I've actually had to scale back my use of them at a prior job for the sake of the team (I was the most expert regex guy by far, but you can't have code that only 1 person is able to modify...) I love them for some reason because 1) they're like puzzles, 2) they're extremely fast if you know what you're doing, vs. doing the same things in interpreted code.