Convert Regular Expressions Between Different Applications

If you found a regex on the Internet that supposedly does what you want, it may not work as intended or at all if the creator of that regex was using a different application than you are. If you previously wrote a script using regular expressions in one programming language and you want to reuse some of those regexes in a new script in another language, then the regex may work differently in the other language or may require a syntax change. Or, you may have upgraded to the latest version of your development tool and found that some regexes work differently because of changes in the regex library.

In all those cases, rely on RegexBuddy to convert your regular expression. You can convert from any regex flavor supported by RegexBuddy to any other regex flavor. RegexBuddy automatically substitutes equivalent syntax. In the screen shot, the backreference ${1} in the replacement text was converted into $1. The . in the regex was changed into [^\n] because the latter does in Delphi exactly what former does in C#. Delphi does support . but it skips more line break characters than in C#.

RegexBuddy warns about subtle differences in behavior when both applications support the same feature but not in exactly the same way. The screen shot shows a warning that both C# and Delphi support start-of-line and end-of-line anchors, but don’t use the same set of line break characters. Therefore, the converted regex may work differently in Delphi than it did in C#. Whether it does depends on how you’ll be using it. In this case, it depends on whether your strings contain line break characters other than line feeds.

Some of these warnings may actually point to bugs in the original regex. If the author of the original regex didn’t use RegexBuddy to analyze the regex, then he or she may not have been aware that the regex would break on strings with different a line break style.

RegexBuddy also attempts to fix syntax errors when converting. If you convert \x{20AC} from C# to Ruby or even to C# itself, you’ll get \u20AC instead of an error saying that \x{20AC} is a syntax error in C#.

Conversion only fails if there’s no way to get a similar result in the target application. A regex using recursion, for example, cannot be converted into a regex flavor that does not support recursion at all.

      
Only US$ 39.95
Windows XP, Vista, 7, 8, 8.1, 10, and 11
100% satisfied or money back


“The best part of RegexBuddy is that I can enter a regex that I wrote in Perl, and can easily convert it to a different language. Sometimes the only option I have is to use VBScript, and being able to quickly and easily convert my Perl regex to VBScript is a huge timesaver.”
— Mick Grove
  22 January 2007, Iowa, USA

Reformat Regular Expressions

Many applications support free-spacing regular expressions which ignore whitespace and line breaks, allowing you to use line breaks and indentation to make the regex more readable, but requiring whitespace to be escaped if you want the regex to match whitespace. RegexBuddy can automatically convert between exact spacing and free-spacing. Converting to free-spacing escapes all literal spaces in the regex. After accepting the conversion you can reformat the regex as you like. Converting to exact spacing removes all formatting spaces and unescapes all literal spaces.

Many applications allow comments in the regular expression. RegexBuddy can preserve or strip comments when converting a regular expressions. Stripping comments is useful when your target application only offers a tiny one-line edit control to enter your regular expression.

If you just want to change the spacing or strip comments, you can select the same application as both the source and target for the conversion.

Converting Replacements and Split Options

In Replace mode, RegexBuddy converts the replacement text along with the regular expression. You can see this in the screen shot.

In Split mode, RegexBuddy will alert you if the two applications split strings differently. Some of these differences can be quite subtle. In particular, regexes that find zero-length matches or adjacent matches can lead to different results. Some applications add empty strings to the split array, while others don’t or only in some situations.

Let RegexBuddy Make Regex Easy for You