Basic Integration with RegexBuddy

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

RegexBuddy’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.

-getfromclipboard

RegexBuddy will use the text on the clipboard as the regular expression. The text is used “as is”, unless you use the -app or -string parameters to specify a string style.

-putonclipboard

RegexBuddy will show the Send button. When clicked, the regex is copied to the clipboard. The regex is copied “as is”, unless you use the -app or -string parametes to specify a string style.

-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 used in the regular expression or replacement text. Something like ?**?**? is a good choice because it’s not something people can or would use in a regex.

If you do not use the -delimitclipboard parameter, then the all the text on the clipboard is used as the regular expression. When clicking the Send button, RegexBuddy only puts the regex on the clipboard.

If you use -delimitclipboard then the clipboard is then interpreted as “regexdelimiteroptionsdelimiterreplacement”. The regex and replacement are interpreted using the string style specified by the -app or -string parameter. The options string is checked for the presence or absence of the following substrings. If a substring is present, that matching mode is turned on. If a substring is absent, that matching mode is turned off. For the line break modes, specifying one of them selects that line break mode. Specifying none of them selects “default” as the line break mode. If your application or regex flavor does not allow a particular mode to be toggled, you don’t need to specify it, even if it is always on.

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

Putting “regexdelimiteroptionsdelimiterreplacement” on the clipboard will put RegexBuddy in Replace mode even if the replacement string is blank. Include splitlimit in the options to put RegexBuddy in Split mode. Omit the second delimiter, the replacement text, and omit splitlimit from the options to put RegexBuddy in Match mode. RegexBuddy will do the same when putting the modified action on the clipboard.

RegexBuddy does not care how or whether you delimit the options, whether you format them as a string, or in which order you place them. RegexBuddy will put them on the clipboard as a comma-delimited list in the order shown in the table. RegexBuddy lists all options that are turned on, even if the application or regex flavor doesn’t allow them to be turned off.

-app app

Specify the application that your regular expression should work with. The app value must be an application identifier. RegexBuddy 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 RegexBuddy to use a certain string format for both -getfromclipboard and -putonclipboard. The stringstyle value must be a string style identifier. If you use both -app and -string, then -string takes precedence.

-flavor flavor

Set the regular expression flavor you’re working with. The flavor value must be a valid regex flavor identifier. If you use both -app and -flavor, then -flavor takes precedence.

-flavorreplace flavor

Set 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

Set 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.

-helpful

Set the flavor emulation mode to Helpful.

-strict

Set the flavor emulation mode to Strict.

-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.

-convertapp app

Specify the application that your regular expression should be converted to. The app value must be an application identifier. RegexBuddy will select this application on the Convert panel. If there is no application identifier for the combination of string style and flavors that you want, then you cannot use the -convertapp parameter. You can use the -convertflavor parameters to specify custom combinations.

-convertflavor flavor

Regular expression flavor that RegexBuddy should select on the Convert panel. The flavor value must be a valid regex flavor identifier. If you use both -convertapp and -convertflavor, then -convertflavor takes precedence.

-convertflavorreplace flavor

Replacement text flavor that RegexBuddy should select on the Convert panel. The flavor value must be a valid replacement flavor identifier. If you use both -convertapp and -convertflavorreplace, then -convertflavorreplace takes precedence. -convertflavorreplace is ignored unless you also use -convertapp or -convertflavor to set the regex flavor.

-convertflavorsplit flavor

Split flavor that RegexBuddy should select on the Convert panel. The flavor value must be a valid split flavor identifier. If you use both -convertapp and -convertflavorsplit, then -convertflavorsplit takes precedence. -convertflavorsplit is ignored unless you also use -convertapp or -convertflavor to set the regex flavor.

-convert

Tell RegexBuddy that the regular expression that it puts on the clipboard must be converted to the required flavor. If you’re using the -convertapp or -convertflavor parameters, then the regex must be converted to the regex flavor specified by those parameters. If not, then the regex must be converted to the flavor specified by -app or -appflavor. If you don’t use any of these 4 parameters to specify a regex flavor or you don’t use -putonclipboard then the -convert parameter is ignored.

If you use this parameter and then click the Send button while a different flavor is selected in the toolbar at the top, RegexBuddy attempts to automatically convert the regex. If the conversion succeeds without warnings, the converted regex is put on the clipboard and RegexBuddy closes. If the conversion fails or has warnings, those are shown on the Convert panel with an additional message that the Send button requires the regex to be converted.

-convertfreespacing

Use in combination with -convertapp or -convertflavor to select “free-spacing” on the Convert panel. Omit to select “exact spacing”.

-convertstripcomments

Use in combination with -convertapp or -convertflavor to select “strip comments” on the Convert panel. Omit to select “keep comments”.

-appname "Application Name"

The -appname parameter must be immediately followed with a parameter that indicates the name of the application that is invoking RegexBuddy. RegexBuddy 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.

-action filename.rba

Loads the regular expression from the specified RegexBuddy action file. Use this parameter if you want to associate RegexBuddy with rba files. This file format is used to share individual regular expressions on the RegexBuddy user forum. If you use -action then the -app through -strict parameters (as listed above) are ignored, because the action file already specifies those.

-testfile document.txt

Loads the file as the test subject on the Test panel.

-testclipboard

Uses the text on the clipboard as the test subject on the Test panel. The text is always used “as is”. Should not be used in combination with -getfromclipboard.

-library filename.rbl

Opens the specified library on the Library panel. Use this parameter if you want to associate RegexBuddy with rbl files.

-grep filename.rbg

Opens the specified GREP action on the GREP panel. Use this parameter if you want to associate RegexBuddy with rbg files.

-activate 1234

Use this parameter in combination with -putonclipboard. -putonclipboard 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, RegexBuddy will use the SetForegroundWindow() 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.