RegexMagic enables you to create regular expressions without having to learn the rather cryptic regular expression syntax. Best of all, RegexMagic itself takes very little time to learn. If you take about 10 minutes to read the getting started topic and work through a few examples, you’ll have a good idea of what you can do with RegexMagic and how to use its capabilities. While RegexMagic doesn’t automatically generate regular expressions on magic alone, it sure makes things a lot easier by allowing you to work with your data instead of the terse regex syntax. You’ll be creating regular expressions in no time.
RegexMagic consists of nine separate panels: Assistant, Samples, Match, Action, Regex, Use, Library, GREP, and Forum. The toolbar at the top has a View menu that provides access to all the panels. It also provides a number of different layouts. If you don’t like any of the layouts, you can rearrange the panels by dragging and dropping their tabs or caption bars with the mouse.
The Assistant panel displays helpful hints as well as error messages while you work with RegexMagic. You’ll want to keep an eye on this panel all the time. If you close it an an error occurs, it will automatically show itself until you dismiss the error.
The Samples panel, Match panel, and Action panel hold all the settings for what is called a RegexMagic Formula. A RegexMagic Formula is simply all the information that RegexMagic needs to generate a complete regular expression, and optionally a replacement text. You’ll be spending most of your time with RegexMagic in these three panels. The toolbar at the top has New, Open, Save, Undo, and Redo buttons that work on RegexMagic Formulas or the contents of these three panels as a whole.
The Regex panel shows the regular expression generated by the RegexMagic Formula that you’ve created. First, select the application or programming language you’ll use the regular expression with. After generating the regex, you can click the Copy button to copy the regular expression formatted as a string for a particular programming language.
The Use panel generates complete source code snippets performing a variety of functions in most of the world’s popular programming languages that you can readily paste into your own source code. That’s often a lot handier than just copying a string with a regex. All the source code templates are fully editable, and you can even create your own.
The Library panel is where you can store your RegexMagic Formulas for later reuse. A RegexMagic Library is a single file that holds as many RegexMagic Formulas as you care to add to it. RegexMagic ships with a sample library that includes all of the examples described in this help file. The help file topic for each sample mentions which formula to select in the library.
The GREP panel uses your regular expression to search through files and folders, just like the traditional grep utility. This is a quick way of testing your regular expression on a larger set of files than is practical with the Samples panel. It also allows you to run actual searches.
Finally, the Forum panel is where you can discuss RegexMagic and regular expressions with other RegexMagic users. Since the forum is built right into RegexMagic itself, you can easily attach RegexMagic Formulas to your messages.
In RegexMagic, you create a regular expression and optional replacement text by building up a RegexMagic Formula using the Samples, Match, and Action panels. The settings on these three panels are all RegexMagic needs to generate a regular expression and a replacement text. Combined, these settings are called a RegexMagic Formula.
Start with adding samples of the text that your regular expression should match to the Samples panel. Don’t forget to also add samples of the text that your regular expression should not match. Use the toolbar and list at the left hand side of the panel to add as many samples as you like. You can load text files or paste in text from the clipboard. You can edit the text of the sample you’ve selected in that list in the edit control to the right of it. Read the how to topic for details.
With the samples in place, it’s time build up your regular expression. The best way to learn how to create regular expressions with RegexMagic is to work through a few examples. The email pattern example is a simple example. The example for SKU codes shows how you can create regular expressions that match anything you want with RegexMagic, even things for which there’s no cookie-cutter pattern. Read the how to topic for details.
If you want to extract parts of the text matched by the regular expression, or if you want to use the regular expression in a search-and-replace, read the how to create capturing groups and replacement text topic to learn how to use RegexMagic’s Action panel.
Finally, all that’s left is to generate the regular expression and to put it to use. The how to use your regular expression topic explains the best ways of copying your regular expression from RegexMagic into the application or source code you want to use it with.
When you’re done, you can use the Save button on the top toolbar to save your RegexMagic Formula into a file of its own. If you want to store many different formulas, it may be handier to add your formulas to a library instead. Then all your formulas will reside in a single file that you can easily work with on the Library panel.