Live data from Hacker News

You Should Learn Regex

blog.patricktriest.com

11–20 of 57 posts

Re: You Should Learn Regex

#11
When I used to code in Perl (more than ten years ago) I tended to solve many many things using regexes. I tried to reduce many programming challenges into transformations that I could do via regexes. Why? Because regular expressions are first class citizens in Perl. And Perl made me learn and use them. (Reminds me of a an APL programmer that saw vectors everywhere.)

When I replaced Perl with Python in my toolbox I abandoned regexes altogether because I didn't know too many Python programmers using regexes.

Now a decade later I am realizing how often I do need regexes in my day to day tasks (using them in bash commands, in my editor, and even in Python sometimes).

Re: You Should Learn Regex

#13
post #6

> From validating email addresses Guys, no. Send an email. https://davidcel.is/posts/stop-validating-email-addresses-wi...

Depends on the use case. For forms, a preliminary sanity check doesn't hurt, e.g. when the user enters their username and password, instead of email & password (accepting either would be best, but you can't always do that).

Mailcheck is great for this. People constantly make typos when entering emails. This utility suggests john.doe@gmail.com if they type in john.doe@gnail.com. But, it's their choice...it just suggests corrections.

My logs show that it helps a lot. Bounced emails from orders dropped by more than half.

https://github.com/mailcheck/mailcheck/blob/master/README.md

Re: You Should Learn Regex

#14
post #11

When I used to code in Perl (more than ten years ago) I tended to solve many many things using regexes. I tried to reduce many programming challenges into transformations that I could do via regexes. Why? Because regular expressions are first class citizens in Perl. And Perl made me learn and use them. (Reminds me of a an APL programmer that saw vectors everywhere.) When I replaced Perl with Python in my toolbox I ab…

Some elucidation on this point:

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

Re: You Should Learn Regex

#15
post #11

When I used to code in Perl (more than ten years ago) I tended to solve many many things using regexes. I tried to reduce many programming challenges into transformations that I could do via regexes. Why? Because regular expressions are first class citizens in Perl. And Perl made me learn and use them. (Reminds me of a an APL programmer that saw vectors everywhere.) When I replaced Perl with Python in my toolbox I ab…

Some elucidation on this point: https://blog.codinghorror.com/regular-expressions-now-you-ha...

Great read. Thanks for sharing.

Re: You Should Learn Regex

#17
Regular expressions are super powerful and a great tool to have at your disposal. The best resource on the topic is the book "Mastering regular expressions" published by O'Reilly. Understanding the inner workings of a regular expression engine will improve your regular expressions. If you use regular expressions a lot, mastering them will be worth it.

Re: You Should Learn Regex

#19
post #11

When I used to code in Perl (more than ten years ago) I tended to solve many many things using regexes. I tried to reduce many programming challenges into transformations that I could do via regexes. Why? Because regular expressions are first class citizens in Perl. And Perl made me learn and use them. (Reminds me of a an APL programmer that saw vectors everywhere.) When I replaced Perl with Python in my toolbox I ab…

I found the same thing. When I was writing Perl half the point was using regex. I inherited a site about 5 years ago that was a huge Perl site built entirely on text files and regex. The developer had basically built a database out of text files. He had directories for indexes, associations, etc.

It wasn't pretty to look at but it was still to this day the fastest site I've ever worked on.

Post reply on HN