Regex Guru

Friday, 20 December 2013

Regular Expressions Quick Reference

Filed under: The Guru's Kitchen — Jan Goyvaerts @ 8:59

The Regular-Expressions.info website has a new quick reference to regular expressions that lists all of the regex syntax in one single table along with a link to the tutorial section that explains the syntax. The quick reference is ordered by syntax whereas the full reference tables are ordered by feature. There are multiple entries for some of the syntax as different regex flavors may use the same syntax for different features.

Use the quick reference if you’ve seen some syntax in somebody else’s regex and you have no idea what feature that syntax is for. Use the full reference tables if you already know the feature you want but forgot which syntax to use.

Of course, an even quicker reference is to paste your regex into RegexBuddy, select the application you’re working with, and click on the part of the regex you don’t understand. RegexBuddy then selects the corresponding node in its regex tree which summarizes exactly what the syntax you clicked on does in your regex. If you need more information, press F1 or click the Explain Token button to open the relevant page in the regex tutorial in RegexBuddy’s help file.

Thursday, 19 December 2013

Compare and Convert Regular Expressions Between Different Applications

Filed under: The Guru's Kitchen — Jan Goyvaerts @ 5:06

The big change in RegexBuddy 4, released this September, is that RegexBuddy now emulates the regex flavors that it supports far more accurately. While RegexBuddy 3 did a pretty good job of telling you which syntax each flavor supported, RegexBuddy 4 also knows exactly how each feature works in each regex flavor. Even fundamental tokens like the dot behave differently in different applications (the dot doesn’t match line breaks in most applications and there’s quite some variety in which characters are considered line breaks).

RegexBuddy 4 now differentiates between many different versions of the regex flavors that it supports. Where RegexBuddy 3 had only “Java”, RegexBuddy 4 knows the differences between Java 4, 5, 6, and 7. All in all RegexBuddy 4.0 supports 126 different applications if you count all the versions and variations separately.

This new attention to detail made two new features possible: regex flavor comparison and regex flavor conversion. On the Create panel, you can now select additional applications. RegexBuddy will analyze your regex for all these applications at the same time. The regex tree will point out all of the differences, or tell you that there are no differences. This is a great feature if you’re writing a regex that will be used in a shared library that needs to work with multiple versions of a programming language. It’s also great for learning a new regex flavor by comparing regexes you created before between the flavor you know and the flavor you’re learning. You can compare any regex between any and all of the flavors supported by RegexBuddy.

If you want to use a regex that was created for a different application, or if you want to port a regex to a new version of your application or programming language, convert it on RegexBuddy’s new Convert panel. RegexBuddy automatically substitutes equivalent syntax and warns you about any subtle differences in behavior in the two applications that affect your regex. Because RegexBuddy tells you what to expect, you can test the converted regex in a far more deliberate manner. Differences in which characters are seen as line breaks by the dot, for example, won’t show up when testing the regex unless you provide sample text with varying line break styles.

RegexBuddy’s website has just been updated to provide some more details about these two features along with a couple of screen shots: