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

> Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

Jamie Zawinski



This is a funny quote. I really hope it doesn't keep people from learning regular expressions, which are actually not as hard as they are often portrayed and extremely powerful and efficient, as demonstrated in this post.


Sure it's powerful and a lot of them are easy. But there's a lot of indecipherable regexes in the wild. I guess you need to learn them anyway, but I'm very strict about using them in production


This is probably an ideal case though. Regular expressions are a part of the JavaScript standard, so there's no excuse for someone that programs in JavaScript to not know at least the basics, and this is almost as basic as you can get.

The alternative is what, a simple tokenizing parser? I think that's actually a step squarely into territory of making it more complex and less readable than a simple regular expression is.


> He wrapped himself in quotations - as a beggar would enfold himself in the purple of Emperors.

Kipling


I'd normally bristle against RegExp hate (unless the RegExp is complex), but in this case, please, just use `URLSearchParams`.

It's well-adopted (unless you have to support IE: <https://caniuse.com/?search=URLSearchParams>)


the song of re̸gular exp ression parsing will exti nguish the voices of mor tal man from the sp here

https://stackoverflow.com/questions/1732348/regex-match-open...




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

Search: