Library Panel Reference

On the Library panel you can store your RegexMagic formulas for later reuse. A RegexMagic formula consists of everything you specify on the Samples, Match, and Action panels. That is everything RegexMagic needs to generate your regular expression and replacement text.

In the layouts, you can access the Library panel by clicking on the Library tab. In the default layout, you can find that tab near the top of the RegexMagic window. In the dual monitor layout, the Library tab is on the floating panel on the second monitor.

Press Alt+7 on the keyboard to move keyboard focus to the Library panel, and to make it visible if it was hidden. Or, select the Library item in the View menu. You can access that menu by the View button on the Assistant panel, and by right-clicking on the caption or tab of any panel in RegexMagic.

Storing RegexMagic Formulas in Libraries

When you have gone through the effort of providing samples and specifying what you want to match and what action you want to take with it to generate a regular expression, it would be a waste to use it just once. It makes a lot of sense to store the RegexMagic formulas you create for later reuse, by yourself or by friends and colleagues.

A RegexMagic formula consists of the samples that you provide on the Samples panel, the fields and patterns that you define on the Match panel, and the capturing groups and replacements that you specify on the Action panel. Everything shown on these three panels is always saved together as one formula.

To save a RegexMagic formula, switch to the Library panel in RegexMagic. If you want to store it into an existing library, click the Open button to select the RegexMagic 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 RegexMagic Library are saved automatically. RegexMagic makes sure that you never lose any patterns you worked so hard on. If you open the same library in more than one instance of RegexMagic, RegexMagic 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 tab’s toolbar.

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

Since RegexMagic 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 RegexMagic 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 Formula to The Library

First, you need to use the Samples, Match, and Action panels to create your RegexMagic formula. 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.

After you add the formula to the library, it appears at the right hand side of the Library panel. The middle area displays a summary of the Match and Action settings. The bottom area shows a drop-down list with all the samples in the formula, and the full text of the selected sample.

Don’t forget to type a clear description in the edit box just below the Library tab’s toolbar. You can enter as much text as you want. A good description will greatly help to look up the regex later. The first line of the description appears in the list at the left. The list at the left shows all the formulas in the library, alphabetically sorted by their descriptions. If a regex does not have a description, it is listed as (untitled).

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 will replace the library item’s regular expression with the one you’re currently editing in RegexMagic. Click the Update button and select to update the sample to replace the library item’s sample with the text currently on the Test tab. Both updates will leave the description unchanged.

Copying and Pasting Formulas Between Libraries

Each instance of RegexMagic can open only a single library. If you want to move or duplicate regex actions between two libraries, start a second instance of RegexMagic. Then use the Cut, Copy and Paste buttons on the Library toolbar to move or copy a formula from one instance of RegexMagic to the other.

If you open the same library in more than once RegexMagic 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.

Using a Formula from a Library

On the Library panel, click the the Open button to open the RegexMagic library from which you want to reuse a RegexMagic formula. 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 RegexMagic’s Library tab, the list of libraries that you recently worked with will list the standard RegexMagic library that is included with RegexMagic itself. This library contains a wide range of samples that you can use to learn how RegexMagic works, and adapt for your own purposes.

To use a formula from the library, select it from the list at the left, and click the Use button. This replaces everything on the Samples, Match, and Action panels with what’s in the formula you selected in the library. You can then immediately generate the formula’s regular expression, or you can adapt the formula first and then generate your regular expression.