Online regular expression generator
Written by Nikos Vaggalis   
Monday, 28 November 2011

A new, free-to-use website provides a regular expression generator that aims to take the headache out of forming and using regular expressions.

 

txt2re.com is a site that aims to help programmers to find out how to use regular expressions and provide an easy-to-use resource for those just looking for a quick hack matching text, without having to bang their heads against the keyboard trying to figure how to compose a regex out, which admittedly in many cases might appear as an obscure task.

It takes an interesting approach - you don't get to write the regular expression yourself and then find out if it matches against the string, the approach that most tools follow, but you start the other way around.

You start by entering the input string which the site then parsers into individual tokens. After that you choose the elements you want to match by just clicking on them; this action generates a regular expression together with the associated code around it.

 

regexauto

 

Although this approach is very simple, and indeed intuitive, it has the limited capability that, since you don't get to write the regex yourself, you can't use advanced features such as lookarounds and atomic constructs since the generator cannot guess what you are after. But as always the choice is based on using the right tool for the right situation at hand

What is also interesting is that you get to see code generated in various languages, Perl, of course, Ruby, Java, C and C# amongst others which acts as a language comparison.

As it seems all languages are Perl regex compatible, with C even importing the PCRE library (#include ), but what differs is the code wrapped around the generated regular expression. It is evident that Perl code is shorter and more succinct while some languages like C# have to build a regular expression object (Regex r = new Regex)

Saying that, it would be convenient to generate POSIX compatible expressions as well, so they could be used with tools like Sed or Awk

A fun and useful site which makes the construction of regex portable; you never know when you will be in need of hacking a quick script while on the road.

More

txt2re

 

To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+, Twitter or Facebook or sign up for our weekly newsletter

 

Banner


Npgsql Adds Support For Visual Studio Data Designer
09/09/2014

The latest release of Npgsql also adds improvements for Entity Framework and support for Postgre 9.4’s JSONB data type.



Intel's New Edison Is As Small As A Postage Stamp
15/09/2014

It is difficult not to see the Edison and think "Arduino killer" and perhaps for some applications "Raspberry Pi killer". In fact it has a place in the low cost tiny system ecology all of its own.


More News

Last Updated ( Monday, 28 November 2011 )
 
 

   
RSS feed of news items only
I Programmer News
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.