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

I agree, the correct one (+500 chars) looks like a maintenance nightmare to me. I tried to build a real e-mail address validator that would accept also the more exotic forms and there was no way in hell I would have done that in regex.

I also met very few people that actually understood regex. It's a whole new skill and if I use it in my application I don't know if the next guy can pick it up.



It's why you should always write regex (at least, anything beyond a couple of characters) using the `x / PCRE_EXTENDED` flag. It makes them ignore whitespace and anything following a #, so you can split your regex up onto multiple lines and comment it to explain what it's doing.


Here's the documented version: https://gist.github.com/dperini/729294

We should get a port to every language.




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

Search: