About the only thing that all regular expression engines have in common is that its designers always try to come up with “new and improved” regex features. The result is that there is a lot of inconsistency in the regex syntax supported by various applications and programming languages. Even different versions of the same application or language can interpret a regex differently. Fortunately, RegexBuddy takes care of all that for you.
When creating a new regular expression, you should select the regex flavor appropriate for the tool or language in which you plan to use the regular expression before creating the regular expression. You can do so via the drop-down list in the top left corner of RegexBuddy’s window, or by pressing Alt+F on the keyboard (F for “flavor”). Your favorite applications are shown directly in the list. By default, these are the latest versions of the most popular applications that RegexBuddy supports.
Selecting a different application in the list changes the way RegexBuddy interprets the active regular expression. It does not modify the regular expression. When pasting a pre-created regular expression into RegexBuddy, select the application the regular expression is intended for, even if it is different from the one you intend to use the regular expression with. If you want to convert a regular expression to a different application, use the Convert panel.
Select “More applications and languages” at the top of the list or press Alt+F1 on the keyboard to show a dialog box with the complete list of predefined applications and languages. The ones you tick in the dialog box are the favorites shown directly in the drop-down list. The built-in applications cannot be edited or deleted. But you can edit their associated source code templates.
An “application” in RegexBuddy is a group of five settings:
When adding custom applications, you are limited to selecting predefined regex, replacement, and split flavors. Because the flavor definitions are very complex, you cannot create your own. You can select them in combinations that were not previously used in any application. If you’re working with an application or programming language that uses a regex, replacement, or split flavor that is different from any of the flavors supported by RegexBuddy, you can let us know as a feature request for future versions of RegexBuddy.
You can select a custom source code template for custom applications. First, click the Edit button to open the template editor and save the new template. Close the template editor and then select the newly saved template for the custom application.
Accurate emulation of an application’s regex flavor can sometimes get in the way of helping you create regular expressions, particularly if you’re working with a regex flavor that is different than the one you normally use. To alleviate this, you can toggle RegexBuddy between Helpful and Strict mode via the drop-down list that sits right next to the applications drop-down list. In Helpful mode, RegexBuddy tries to be helpful and point out potential mistakes in your regex. In Strict mode, RegexBuddy emulates the selected application exactly, even in situations where the application’s behavior isn’t very sensible.
In Helpful mode, RegexBuddy also helps you deal with deficiencies in the emulated application’s regex engine. For example, Java has various issues when dealing with character class intersection. Java’s documentation specifies [a-z&&[def]] as the proper syntax. In reality, [a-z&&def] works just as well. Things get complicated when you mess up the syntax. Java does not treat [a-z&&[def]ghi] as an error. It interprets it as [a-z&&ghi], completely ignoring the [def] part. With Java selected in Strict mode, RegexBuddy does the same. In Helpful mode, RegexBuddy treats [a-z&&[def]ghi] as an error, pointing out that ghi overwrites the [def] part. But if you select Ruby as your application, there is no difference in Helpful or Strict mode. In both modes, RegexBuddy will treat [a-z&&[def]ghi] as [a-z&&defghi] which is what Ruby does and what makes sense.