Online regular expression generator
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


Intel Euclid - New Horizons For RealSense
22/08/2016

Intel demoed a prototype of Euclid at last week's Intel Developer Forum. This is a compact computer combined with RealSense 3D depth sensing technology that can serve as the brain and eyes of a robot. [ ... ]



Microsoft Open Sources PowerShell And It Runs On Linux
22/08/2016

PowerShell is a strange beast that has now been let loose on Linux as well as Mac. You could even say "on the world" as it is now open source. What is PowerShell and why should you care?


More News

Last Updated ( Monday, 28 November 2011 )
 
 

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