Select Your Application or Programming Language

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.

Drop-down list with favorite applications and programming languages

More Applications and Languages

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:

  1. Regular expression flavor: The syntax supported by and the behavior of the regular expression engine used by this application.
  2. Replacement text flavor: The replacement text syntax, if any, supported by this application.
  3. Split flavor: The behavior of this application when splitting a string along regex matches, if supported.
  4. String style: Rules for formatting a regex or replacement text as a literal string when copying and pasting.
  5. Template for source code snippets: Template for generating code snippets on the Use panel. Click the Edit button to edit a template or to create a new one.

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.

Select target application for your regular expression

Helpful or Strict Emulation Mode

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 helps you deal with unsupported syntax. For example, you may be used to using \A to match the start of the string. But in JavaScript, \A matches a literal A. In Helpful mode, RegexBuddy assumes that if you wanted to match A literally, you'd just enter A as your regex. So if you enter \A, RegexBuddy takes the liberty of telling you that JavaScript does not support \A as a start-of-string anchor. If you double-click the error on the Create panel, RegexBuddy will replace \A with ^ which JavaScript does support. In Strict mode, however, RegexBuddy will tell you that \A matches a literal A in JavaScript, and behave that way on the Test panel.

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.