regex visualize.png




We’ve posted all kinds of various regular expression builders (RegExr, Rejex, and ReguLazy) to help verify that the regex you’re using will match the content it is running against. When you’re just learning regular expressions those tools might be a little confusing, and so we thought we should offer up a couple free sites that should help out beginners.

The strfriend site lets you input a regular expression that you’ve come up with and it will build a visual representation of how the expression will be processed. The screenshot you see above is from strfriend, and is a breakdown of how the regex will be executed against some text. The example in the screenshot is below, and can identify an email address:

^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$

The txt2re site is another helpful companion that lets you type in sample text that you want a regular expression from, and you’ll click you’re way through building the regex. Once you’re done it will pump out code that can be used in Perl, PHP, Python, Java, Javascript, ColdFusion, C, C++, Ruby, VB, VBScript, J#.net, C#.net, C++.net, and VB.net. The code it generates isn’t necessarily the best way to attack a particular regex, but it’s a good starting point for new programmers.

Let us know if you’ve come across any helpful regex tools that you use on a regular basis.