Working with Regular Expressions

Tags:

Regular Expressions – you either love them or hate them, and usually when you hate them, you just haven’t spent enough time trying to learn them! :)

They are incredibly useful, but they can often be difficult to build and test. I have previously mentioned a great tool called RegexBuddy, which is a great help.

However, being a Windows application, you might not always have your PC with it installed around. I’ve often found myself stranded, looking for a quick way to write and test a regex.

I decided to fix this problem once and for all: Say hello to the JavaScript Regex Tester!

The obvious solution – a web-based one

The solution to the problem posed by not having a regex tool with you is to make a regex tool which is always (or at least most of the time) accessible… Thus make it a web application!

I decided to write some simple JavaScript code to run and test regular expressions and display the resulting match and submatches. The result is the JavaScript Regex Tester.

The tester does not work without JavaScript enabled, which could be thought of a problem for users on mobile devices… but how often do you find yourself writing code with your phone? I’d say not very often – more like “never”.

Because it’s solely JS based, it’s also faster than doing round-trips to the server to fetch results with Ajax or such, so it’s nicer to use.