I know Regex is cool.
But.
Here's the problem:
Everytime I come across a problem where I think, "Regex would be perfect for this."
I have to learn it all over again.
Because these problems only come up once or twice a year for me.
« Exhibit E | Main | Schizoid Launches In July »
The comments to this entry are closed.
I've found RegexBuddy to be invaluable for those situations. There are probably free versions of the same app, but I keep coming back to this one. It's especially handy if you have to switch between multiple Regex engines (for me .NET, Javascript, etc) and gives examples of using your Regex with the engine of your choice.
Posted by: Matt Rudder | June 17, 2008 at 03:13 PM
I've actually found regular expressions can be used much more frequently.
Still, if you need a refresher, print out this cheat sheet and blu-tac that sucker somewhere noticeable:
http://www.ilovejackdaniels.com/regular_expressions_cheat_sheet.png
Posted by: Josh | June 17, 2008 at 03:47 PM
Regex Coach is my tool of choice here -- not quite as nice as RegexBuddy, but free (not that I mind paying $40, it just saves me the time it takes to buy). Like RegexBuddy, a Windows-only tool (there's an old Linux version on the site, though).
Posted by: Austin | June 17, 2008 at 11:33 PM
Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.
Someone just had to post the ever famous quote, right?
Posted by: Aras Pranckevicius | June 18, 2008 at 12:04 AM
I prefer the online version, RegexPal: http://regexpal.com/
Posted by: Adam | June 18, 2008 at 01:23 AM
I have this same problem all the time! I printed out a cheat sheet, then couldn't find the bit of paper when I needed it. And even if I had've found it, I probably would've found that the tool I want to use regex in is a slightly different flavour to the one I printed out, and end up replacing all spaces in my file with a W...
Posted by: Russ | June 21, 2008 at 03:01 AM
As a user I prefer to not only know that the (bad) email I entered is invalid, but also why. All regex checking I've seen only does the first. This is why I prefer to write a small parser instead :)
Posted by: sirGustav | June 27, 2008 at 10:01 AM
"As a user I prefer to not only know that the (bad) email I entered is invalid, but also why. All regex checking I've seen only does the first. This is why I prefer to write a small parser instead :)"
Huh?
That makes no sense. If you want to know which particular rule a bad email violates, you just write several regexes? One that checks whether you have exactly one @, one that checks that there are no invalid characters, and so on.
I mean, you have the same problem with a parser. A parser doesn't magically tell you "your email address is bad because no such domain exists". It tells you that it couldn't match rule X, and therefore it's not valid. Just like a regex does.
But so true about having to learn regexes again every time you need them. I do that too, and it's driving me mad. Will have to check out regexpal or some of the other suggestions.
Posted by: grumpy | July 03, 2008 at 03:40 AM