The Regex Coach
For all but the most die-hard programming propeller-heads, the term “regular expression” is liable to bring out a cold sweat.
True, they’re incredibly powerful …
… but they’re also incredibly hard to get your head around.
So, what is a regular expression (aka regex or regexp)?
Well, in a nutshell (a Wikipedia nutshell, to be precise), they “provide a concise and flexible means for matching strings of text, such as particular characters, words, or patterns of characters. A regular expression is written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.”
Clear as mud, then, isn’t it?
Suffice it to say that they allow you to do very complex string matching and replacement, by defining precise patterns of allowable characters, using a specific set of command codes.
They may be used, for example, to validate that a telephone number or postal code is in the correct format, or that a password does not contain characters that aren’t allowed.
Their uses are really only limited by your imagination …
… and your ability to understand the syntax of regular expressions.
And it is VERY easy to get these wrong, which means you can spend ages trying to debug why they’re not working the way you thought they should.
The good news is that there is a tool, called The Regex Coach, that makes it really easy to test your regular expressions out in a safe, test environment.
This tool (which is free, by the way) provides visual feedback too, so you can tell at a glance if you’ve got your regex right or not.
It’s really hard to do justice to this great tool, created by Dr Edmund Weitz, especially when describing regular expressions is already tough.
So, if you’re struggling with these monsters, go and grab yourself a free copy of The Regex Coach and you’ll be able to stop tearing your hair out in no time at all.
(And if you like it, as I’m sure you will, I have no doubt that Edi would appreciate a small donation, which is what I did as a small token of my thanks for making this invaluable aid available for nothing.)
Tags: parser generator, test environment, regex coach, no doubt, postal codeBELIEVE IT OR NOT:
Powered By Odd Facts