Live data from Hacker News

How "junior" developers can become regex wizards

joshuakemp.blogspot.com

1–10 of 46 posts

Re: How "junior" developers can become regex wizards

#4
This might be overkill but I found I never "got" regular expressions until a class made me think about them as state machines. The additional bashing over the head of having to implement a parser/matcher made it really stick. The quirks and syntax make much more sense when you know why and how a regex engine works.

That said, anything involving extended/perl regex I wind up googling.

Re: How "junior" developers can become regex wizards

#5
A couple things:

1. Be careful what you use regex's for. Email addresses are very difficult[0]. HTML is impossible[1].

2. There are a number of tools that make it easier to understand, including [2].

[0] http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html

[1] http://stackoverflow.com/a/1732454/2363

[2] http://ivanzuzak.info/noam/webapps/fsm_simulator/

Re: How "junior" developers can become regex wizards

#6
You don't need to be a developer or a wizard to be proficient in writing regular expressions. Regular expressions are used by all kinds of professions; that's why regular expression capability is included in almost every text editor.

The best way to learn to love regular expressions is to use them outside of a programming context, where you can get real-time feedback with actual test data. Some text editors will even highlight matches as you type the expression out.

Re: How "junior" developers can become regex wizards

#8
I love these types of things. Kudos to the author.

This one in particular reminds me of a tool I've always found useful. It's an interactive Regex builder just like the one linked in the OP. I would say it's got some additional compelling features: like mouse-over breakdowns of each expression as you build it, a handy reference list as well, but also a community concept and saved expressions. Really, I've never found anything better. My only complaint is that it's flash-based, but it's an amazing tool, so can't really complain too much.

http://gskinner.com/RegExr/

Re: How "junior" developers can become regex wizards

#9
ugh.

do they really need to be good at regex? we don't all work on the internet you know... regex is basically pointless for most application development. most programmers i consider to be exceptionally talented can not write a regex without reference (although they will do it when necessary by using reference - and very well too).

on the other hand the general approach to problem solving advocated here is quite sound. "find good tools" "don't rush pointlessly" "measure don't guess" "google is good, copy-paste blindly is bad"

Re: How "junior" developers can become regex wizards

#10
post #5

A couple things: 1. Be careful what you use regex's for. Email addresses are very difficult[0]. HTML is impossible[1]. 2. There are a number of tools that make it easier to understand, including [2]. [0] http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html [1] http://stackoverflow.com/a/1732454/2363 [2] http://ivanzuzak.info/noam/webapps/fsm_simulator/

[0] Yep. Although, to be fair, that is simply a generated expression based on what I assume are much simpler starting rules. That said, and this is a topic that never ceases to come up, be simple and be lenient.

For every person who thinks their use case is special, it probably isn't. It is almost always better to do trivial validation that allows false positives than to try to be exact and forget a corner case (and, most likely, you'll end up forgetting multiple corner cases).

Want to help users with typos in email addresses without rejecting them? Use something like mailcheck:

https://github.com/Kicksend/mailcheck

And, tons more discussion here: http://stackoverflow.com/questions/201323/using-a-regular-ex...

[1] Yep. That said, it is apparently useful for certain parts of HTML parsing/validation, as AntiSamy I believe uses regular expressions frequently. https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Proj...

Post reply on HN