

Breaking It Down: Regular Expressions for Regular Programmers - jlgosse
http://www.mobilitea.com/blog/2009/07/22/breaking-it-down-regular-expressions/

======
mahmud
Or you can learn regexes interactively:

<http://weitz.de/regex-coach/>

I personally use Emacs' regex-builder mode to get quick visual feedback on
what a pattern matches on a given input data before I set it loose. (regex-
coach is Perl compatible but emacs is not; I frequently type [0-9]+ in emacs
to mean \d+)

~~~
profquail
Or, you build them online with this neat Javascript-based tool:

<http://www.gskinner.com/RegExr/>

~~~
gojomo
I'm biased, but I like mine better:

<http://regex.powertoy.org>

~~~
jlgosse
I find txt2re pretty much unusable

~~~
jbrennan
You sly dog, you.

------
teilo
Honestly, if you are a "Regular" programmer, then RegEx would not be a problem
in the first place. Without them, you are more of a "stunted" programmer.

Far better than cludges and crutches is a good RegEx tester, for example:
<http://www.regextester.com/>

Put in the real deal. Put in what you expect to match, and tweak until you get
it right and understand why it wasn't working before.

~~~
jlgosse
I agree with most of what you had to say. I do not, however, agree with the
first part of your comment. A lot of gifted programmers simply have no real
need to use regular expressions, especially if they develop primarily in Java.
This is just unfortunate for them, as they end up not learning them at all.
This doesn't necessarily mean they are "stunted", but just unlucky.

------
mrinterweb
I don't understand what is difficult about regular expressions. Yes they are
cryptic, but they are very straight forward when you understand the syntax. At
work I have become the goto guy for all things regular expression related. The
developers that ask me for Regex help are not junior programmers either. Maybe
the cryptic nature of regex just turns people off or scares them.

------
Tichy
I suspect problems with understanding regular expressions are really just
psychological.

~~~
johnwatson11218
The biggest problem I have with regular expressions is all the differences in
syntax between java, ruby, grep etc. I find that I could use them about every
other week but I have to go and google for how to use them in each
environment. It isn't just the difference between how to say "match digits"
but in java you use a few lines of oo code whereas in ruby there is an
operator ~= to match or replace. Then oracle started to support them in one of
the more recent releases. So that is yet another syntax/api to learn. I find I
can remember how to do the basic searches but for anything more advanced I
have to spend a while debugging it.

------
joe_the_user
For me, none of this cleverness really solves the problem that regular
expressions represent for building a large application.

For example, I found code that generates expressions like "(^|)Terminal(|)" in
running mono code in a project I'm working on. I have played with REs a fair
amount and I don't know exactly what this should do or why. But it's been
doing it for a while.

Sorry, but most Regexing should be avoided unless you have a really good
reason. Use system calls to parse file paths, use a really parser to parse a
DSL, and so-forth.

