How "junior" developers can become regex wizards
joshuakemp.blogspot.com
How "junior" developers can become regex wizards
1–10 of 46 posts
Re: How "junior" developers can become regex wizards
#21. Write a bunch of regular expressions.
2. Fix them when they break.
Anybody can do this, however junior they may be. (And yes, it does grant you a superpower.)
Re: How "junior" developers can become regex wizards
#3Re: How "junior" developers can become regex wizards
#4That said, anything involving extended/perl regex I wind up googling.
Re: How "junior" developers can become regex wizards
#51. 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
Re: How "junior" developers can become regex wizards
#6The 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
#7Re: How "junior" developers can become regex wizards
#8This 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.
Re: How "junior" developers can become regex wizards
#9do 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
#10A 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/
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...