Regular Expression Generator

There are times in every programmer’s life when we need to write a regular expression. It sounds really, really simple but believe me – it’s not easy at all. If you don’t deal with regular expressions day-to-day it can be truly painful process. How to make it simpler?

Fortunately for us all, there are some useful tools on the net that make generating regular expressions much less painful. My favourite one is txt2re generator, which allows us to create expression extracting given data by simply clicking on correct parts of data string.

Txt2re website generates expressions code for most programming languages: Perl, PHP, Python, Java, Javascript, ColdFusion, C, C++, Ruby, VB, VBScript, J#.net, C#.net and VB.net.

txt2re - Regular Expression Generator
txt2re – Regular Expression Generator

Usage is very simple and intuitive: first enter string you are trying to process – it may be output of some website or whatever you are trying to extract. Then press “Show Matches” and you should see the string parsed into colorful pieces. Here is where the magic happens: by clicking left or right part of any chunk we can make adjustment to matching expression. Left part always uses generic match (word, variable, character etc) while right part gives us possibility to match against specific data (letters and strings).

Do you know any other interesting tools? Let us know via Suggest An App!

While there are several limitations to this method, I tested it with real problems and it works fine! If generated regular expression needs further tuning, it is very easy due to way how expression is generated. Txt2re can really save you day!

Check txt2re yourself!

2 Comments

Add a Comment