Monday, July 23rd, 2007

Regular Expression Tool Released

Category: JavaScript, Utility

Erik Arvidsson has posted about a new Regular Expression Tool that he just created. The tool came about because he started to use Komodo Edit, and the only feature he missed from the full version was the regex editor.

It took me a second to realise that the top box is for the regex and the one below is for the text. Although they are not labeled, the give away is the checkboxes. They would have to go next to the regex :)

This is a little like Donald Norman on doors. Just today it bugged me that a shop had to have huge PUSH and PULL signs because the door had handles on both sides.

The implementation is pretty simple. It uses input/propertychange events to track changes to the text areas and then applies the regular expression to the test text and displays the result in a tree. For the tree I used xTree2b which has been in beta for a few years now…

Regular Expression Tool

Posted by Dion Almaer at 5:12 am
15 Comments

+++--
3 rating from 20 votes

15 Comments »

Comments feed TrackBack URI

been looking for something like this. Thanks. I hate writing Regex but at least this will help ease the pain.

Comment by justin — July 23, 2007

God how I hate Regular Expressions but at the same time I love them. It doesn’t say but I am guessing that this is for POSIX regular expressions only and I mostly use PCRE so it isn’t very useful for me.

I have wished for years that someone would make a regular expression tool that would allow me to paste in a bit of text and then paste in the string I am trying to located and it would then generate the expression needed to find that string in either POSIX or PCRE form.

Comment by Twist — July 23, 2007

Just two words: “Rexv org” – nobody needs YART…
Anyway – nice work….

Greetings,
.mario

Comment by .mario — July 23, 2007

nice link mario
anyone know what Regex type C# uses?

Comment by justin — July 23, 2007

That’s pretty cool. I was thinking about making something like that…

Don’t you hate it when people read your minds and steal your idea’s? But I’m sore mine would have been better :P haha, just kidding.

Comment by Dougal — July 23, 2007

In IE6, you only gets Javascript errors… I use FF as my primary browser, but my co-workers use IE

Comment by Andrea — July 23, 2007

It works fine in IE7 but not in IE6. I assume this was a tool created for personal use? I use Firefox by default so it is no issue to me. I know that nearly 50% still use IE6 but how many of them are developers? Hopefully none LOL!

Comment by justin — July 23, 2007

Twist, the regular expression to find a specific string in a block of text is the string itself. That is, you want to find the string “def” in the text “abcdefghi”, the regular expression to find that is “def” (the screenshot above actually shows this)

Anything more complex like “def but only if it’s followed by g or any number of additional f” would require you to communicate that in some succinct format: a regular expression “((def)(g|f+))” (the parenthesis here are so you can get just the “def” out of the result if the entire expression matches). So I’m not sure how you would overcome this with some kind of tool that just “told” you what regular expression you needed to match a given string.

But that’s the point of these regular expression demo pages — experimentation so you can learn regular expressions by seeing the results.

The major differences between POSIX and PCRE engines is syntax. PCRE is pretty much just a superset of POSIX capabilities that can match a wider range of inputs with a terser and more expressive syntax for some complex patterns. (this is a simplistic description of differences — if you are used to one, you’ll most likely get frustrated with the differences between the character class syntaxes and the differences between the greediness specifiers).

Comment by Andy — July 23, 2007

There really is nothing better than Regexbuddy if you’re using regexes. It’s about 40 bucks, completely worth it, and you’re supporting the development of a really best-of-breed bit of software. Fantastic creation, testing, and all the other tools you need, plus a pretty extensive library, explanation of how regexes work, etc.

http://www.regexbuddy.com/

Comment by jimmy — July 23, 2007

Agent Ransack is a free file search program that has a regex wizard… you can use the wizard for anything you want, and then instead of submitting the resultant string in the file search form, just copy and paste it into your application code. It’s not super powerful but it presents the regex chain in a series of plain-english segments while you’re building the string so that it follows your mental model very closely. It’s not until you have the regex string in the search form that you see the raw regex.

Comment by Mike Ritchie — July 23, 2007

I think the missing part here is…. Komodo Edit Rox0rs!

Comment by Charles — July 23, 2007

I would recommend regex coach. I have used it for about 2 years now.
http://weitz.de/regex-coach/

free as well, looks almost exactly like this web one. Why rewrite what has been done before ….

Comment by ScottD — July 23, 2007

quickRex on Eclipse, anybody?

Comment by Sergej — July 24, 2007

Hi,
I use Regex Coach also, but the online version is a good idea when I don’t have a desktop app on hand.

Comment by Nick — July 24, 2007

Good tool…please add few labels and a brief description it is not very apparent though…estimable

Comment by andhapp — July 24, 2007

Leave a comment

You must be logged in to post a comment.