Using a Regular Expression from a Library

RegexBuddy makes it very easy to create regular expressions, which is nice. But it is even nicer to use ready-made regular expressions provided by others, or reuse regexes that you saved yourself in the past.

On the Library panel, click the the Open button to open the RegexBuddy Library from which you want to reuse a regular expression. Or click the small downward pointing arrow on the Open button to reopen a library that you recently worked with. If this is the first time you are using RegexBuddy's Library panel, the list of libraries that you recently worked with shows the standard RegexBuddy library that is included with RegexBuddy itself. This library contains a wide range of sample regex actions that you can use for various purposes.

To use a regex action from the library, select it from the list at the left, and click the Use button and select to use the regular expression. This copies the regex action to the regular expression area at the top, where you define regex actions in RegexBuddy. Then you can analyze, test and implement the regular expression as usual.

Some library items also have test data associated with them. If you click the Use button and select to use the test data, then the test data is copied to the Test panel in RegexBuddy.

RegexBuddy's library

Correct Application and Mode Settings

Each regular expression in a library is intended for a particular application with a particular set of matching modes. All this is stored with the regex in the library. When you use a regex from a library, those settings are copied over to the application and option drop-down lists on the top toolbars.

If a regex from a library targets a different application than the one you want to use the regex with, first click the Use button on the library toolbar to load the regex and the settings it was saved with. Then, select your target application on the Convert panel. If the conversion goes well, click the Accept Conversion button to finish converting the library regex to your target application. You can now copy the regex into your application or generate a code snippet.

To make sure the regex works as intended, make sure that you set the same matching modes in your actual application. Code snippets generated on the Use panel do this automatically. But if you just copy and paste the regex, you'll need to set those options yourself. You can see them in the drop-down lists on the top toolbar. You can also see them as a comment above the regex on the Library panel.

Substituting Parameters

When storing a regular expression in a RegexBuddy Library, it can be parametrized. When you select a parametrized regular expression and click the Use button, RegexBuddy asks you what you want to substitute the parameters with. Each parameter has a description that explains what you should enter as the value. A default value is also provided. If you can't read the complete description because the column is too narrow, make the parameter window wider. The description column stretches along with the window.

RegexBuddy does not interpret a parameter's value in any way. The parameter's tag is simply replaced with the value, whatever it is. Metacharacters in the value are not automatically escaped. Though this means you have to be a bit careful when entering a value for a parameter, it also enables you to substitute a parameter with a complete regular expression. You can see a preview of the final regular expression, and the replacement text in case of a replace action, as you type in values for the parameters.