Basic Integration with RegexMagic

Integrating RegexMagic with your favorite tools can significantly speed up this workflow by automating most of the steps. The simplest form of integration is by starting RegexMagic with certain command line parameters. This method is appropriate when you want to integrate RegexMagic with a 3rd party tool. If the tool has the ability to run external applications, you can easily launch RegexMagic from within the tool.

RegexMagic’s command line parameters are case insensitive. The order in which they appear is irrelevant, except for parameters that must be followed by a second “data” parameter. The second parameter must immediately follow the first parameter, separated with a space. Values with spaces in them must be delimited by a pair of double quotes. Parameters can start with a hyphen or a forward slash.

-putonclipboard

RegexMagic will show the Send To button. When clicked, the regex is copied to the clipboard. The regex is copied “as is”, unless you specify one of the format options.

-app app

Specify the application that the generated regular expression should work with. The app value must be an application identifier. RegexMagic will use this application’s string style, regex flavor, replacement flavor, split flavor, and source code template. If there is no application identifier for the combination of string style and flavors that you want, then you cannot use the -app parameter. You can use the separate -string and -flavor parameters to specify custom combinations.

-string stringstyle

Tell RegexMagic to use a certain string format for -putonclipboard. The stringstyle value must be a string style identifier. If you use both -app and -string, then -string takes precedence.

-flavor flavor

Specify the regular expression flavor that the generated regex should work with. The flavor value must be a valid regex flavor identifier. If you use both -app and -flavor, then -flavor takes precedence.

-flavorreplace flavor

Specify the replacement text flavor you’re working with. The flavor value must be a valid replacement flavor identifier. If you use both -app and -flavorreplace, then -flavorreplace takes precedence. -flavorreplace is ignored unless you also use -app or -flavor to set the regex flavor.

-flavorsplit flavor

Specify the split flavor you’re working with. The flavor value must be a valid split flavor identifier. If you use both -app and -flavorsplit, then -flavorsplit takes precedence. -flavorsplit is ignored unless you also use -app or -flavor to set the regex flavor.

-template filename.rbsct

Select the RegexBuddy source code template for the Use panel. You can specify the file name of the template without the path and without the extension. If you use both -app and -template, then -template takes precedence.

-delimitclipboard delimiter

Specify a string to use as a delimiter so that more text than just the regular expression can be passed via the clipboard. Your chosen delimiter must not be something that will appear in the regex or replacement text generated by RegexMagic. Something like ?**?**? that isn’t valid regex syntax is a good choice.

If you do not use the -delimitclipboard parameter, then only the regular expression is copied to the clipboard when you click the Send button.

If you use -delimitclipboard then RegexMagic copies the regular expression followed by the delimiter followed by the list of options. No line breaks or whitespace are added around the delimiter. The regular expression is still formatted using the string style specified by the -app or -string parameter. The list of options is a comma-delimited list of options that need to be turned on. Options that need to be turned off are omitted.

caselessCase insensitive
freespacingFree-spacing regex
dotallDot matches line breaks
multiline^ and $ match at line breaks
lblfonlyLF only line break mode
lbcronlyCR only line break mode
lbcrlfonlyCRLF pairs only line break mode
lbcrlfCR, LF, or CRLF line break mode
lbunicodeUnicode line break mode
explicitcaptureParentheses do not create numbered groups
namedduplicateNamed capturing groups can have the same name
ungreedyQuantifiers are lazy and appending ? makes them greedy
skipzerolengthSkip zero-length matches
stringsyntaxSupport literal string escapes on top of the regex or replacement text syntax
splitlimit1234Split action with 1234 as the limit; 1234 can be any positive or negative integer; omit 1234 to split without a limit
splitcaptureAdd capturing groups to the resulting array when splitting a string
splitemptyAdd empty strings to the resulting array when splitting a string

If a replacement text is generated, the options are followed by another delimiter and the replacement text. The replacement text is also formatted using the string style specified by the -app or -string parameter.

-sampleclipboard

Start with a blank RegexMagic Formula and paste the text on the clipboard as a sample on the Samples panel. The text on the clipboard is always used “as is”.

-appname "Application Name"

The -appname parameter must be immediately followed with a parameter that indicates the name of the application that is invoking RegexMagic. RegexMagic will show this name in its caption bar, to make it clear which application the Regex will be sent to. You should always specify -appname when using -putonclipboard.

-formula filename.rmf

Loads the specified RegexMagic Formula file. Use this parameter if you want to associate RegexMagic with rmf files. This file format is used to share individual RegexMagic Formulas on the RegexMagic user forum.

-sample document.txt

Loads the file as a sample on the Samples tab.

-library filename.rml

Opens the specified library on the Library tab. Use this parameter if you want to associate RegexMagic with rml files.

-grep filename.rmg

Opens the specified GREP action on the GREP tab. Use this parameter if you want to associate RegexMagic with rmg files.

-activate 1234

Use this parameter in combination with -putonclipboard. -activate must be followed by a decimal unsigned integer that indicates the window handle of the active top-level form in your application. When the Send To button is clicked, RegexMagic will use the SetForeground() Win32 API call to bring your application to the front. That way, the Sent To button enables you to continue working with that application right away.