Interactively build regular expressions

txt2regex can be interactive or noninteractive and generates regular expressions for a variety of dialects based on user input. In interactive mode, the regex string builds as you select menu options. The sample output here is from noninteractive mode, try running it standalone and see for yourself. It's written in bash and is available as the 'txt2regex' package at least under debian/ubuntu.
Sample Output
$ txt2regex --make date --prog vi,perl

### date LEVEL 1: mm/dd/yyyy: matches from 00/00/0000 to 99/99/9999

 RegEx vi  : [0-9]\{2\}/[0-9]\{2\}/[0-9]\{4\}
 RegEx perl: [0-9]{2}/[0-9]{2}/[0-9]{4}

By: bwoodacre
2009-04-29 04:00:22

What Others Think

That thing is awesome! I'm not too bad with sed regex, but it's a nice gadget with which to tinker.
xizdaqrian · 686 weeks and 6 days ago
hah, this is a lot of fun.
unixx · 686 weeks and 5 days ago
servermanaged · 686 weeks and 5 days ago
There is also a package, 'regexxer' that is a GTK GUI-based perl-syntax regex interface, so you can play around with perl regular expressions on an input file and see the effect of your changes as you write the expression. It doesn't help you build the expressions, just to test them faster.
bwoodacre · 686 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: