Storing Regular Expressions in Libraries

When you have gone through the effort of creating and testing a regular expression, it would be a waste to use it just once. It makes a lot of sense to store the regexes you create for later reuse, by yourself or by friends and colleagues. RegexBuddy makes storing and sharing regex actions easy.

RegexBuddy's library

To store a regular expression, switch to the Library panel in RegexBuddy. To create a new library, first click the New button on the Library toolbar. Then click the Save button to store the library into a new RegexBuddy Library file.

If you want to store it into an existing library, click the Open button to select the RegexBuddy Library file. Or click the small downward pointing arrow on the Open button to reopen a library that you recently worked with.

Any changes you make to a RegexBuddy Library are saved automatically. RegexBuddy makes sure that you never lose any regexes you worked so hard on. If you open the same library in more than one instance of RegexBuddy, RegexBuddy makes sure all the instances are kept in sync, by automatically saving and reloading the library.

In other words: you don’t have to worry at all about making sure your work is saved. As a precaution against inadvertent modifications, all libraries are opened as “read only” by default. You can toggle the read only state with the check box just below the New and Open buttons on the Library panel’s toolbar.

One exception is the sample RegexBuddy library that is included with RegexBuddy. When you open it, RegexBuddy turns on the “read only” state permanently. The reason is that when you upgrade RegexBuddy, the sample library is upgraded too. If you want to edit the sample library, click the Save As button to make a copy.

Since RegexBuddy automatically and regularly saves libraries, there is no button or command for you to do so manually. If you want to edit a library, and preserve the original for safekeeping, click the Save As button before turning off the read only option. Save As tells RegexBuddy to create a copy of the library under a new name. Any subsequent changes are automatically saved into the new file. The original file stays the way it is.

Adding a Regex Action to The Library

First, you need to define the regex action in the topmost part of RegexBuddy’s window. Then, click on the Library panel’s Add button. If the button is disabled, you forgot to turn off the “read only” checkbox on the Library panel, or you did not type in a regular expression yet. You can either add the regular expression by itself, or you can add it along with the text you’ve typed or loaded into the Test panel.

The entire regex action then appears in the lower right part of RegexBuddy’s window. If your regular expression contains parameters like %PARAM%, a grid appears where you can edit the parameters. If you stored a test subject with the regular expression, its text also appears, with regex matches highlighted.

Enter a clear description in the edit box just below the Library panel’s toolbar. You can enter as much text as you want. A good description greatly helps to look up the regex later and to differentiate it from other similar regexes.

The first line of the description is used as the label for the regex in the list at the left hand side of the Library panel. If a regex does not have a description, the list shows the first line of the regex itself.

Updating Regex Actions in The Library

You cannot directly edit regular expressions and test data stored in the library. To change a regular expression, click the Update button and select to update the regular expression. This replaces the library item’s regular expression with the one you’re currently editing in RegexBuddy. Click the Update button and select to update the test subject to replace the library item’s test subject with the text currently on the Test panel. Both updates leave the description unchanged.

Copying and Pasting Regexes Between Libraries

Each instance of RegexBuddy can open only a single library. If you want to move or duplicate regex actions between two libraries, start a second instance of RegexBuddy. You can easily do that by clicking the RegexBuddy button in the History. Then use the Cut, Copy and Paste buttons to move or copy a regex action from one instance of RegexBuddy to the other.

If you open the same library in more than once RegexBuddy instance, both instances are automatically kept in sync. If you make changes in one instance, they automatically appear in the other instance when you switch to it.