Regular Expression and Wildcard Modifiers

Regular expression and wildcard modifiers are supported for various properties in which you can search for a text pattern. These modifiers add special rules to text comparison so that the BarTender action can perform a more precise search for the specified text pattern. Regular expression and wildcard modifiers differ from other special characters in that they are used only to modify a text pattern search, so they are not embedded in the processed data.

Properties that support regular expression or wildcard modifiers display the control to the right of the property. Click to view a list of supported regular expression or wildcard modifiers, and then click the modifier that you want to add to the property.

On some property tabs, you might need to click to select the Use Regular Expression check box to make the control available. On other property tabs, you must click Use Wildcards (* and ?) or Use Regular Expression in the Search Method list.

ClosedExample: Regular Expression Modifiers

Suppose that all Print Command Script trigger files currently print to Zebra printers:

%BTW% /AF="MyFile.btw" /PRN=”Zebra (1)” /P

%END%

You have created a file integration that uses an existing Print Command Script trigger file, but you want to redirect print jobs to Datamax printers. Instead of manually editing all of your trigger files to update the printer, you can add a Search and Replace action that searches for the “ZebraXXX” pattern and replaces it with “Datamax”.

You don’t need to use a regular expression modifier if the pattern is an exact match, such as “Zebra” to “Datamax”. However, if the printing criteria is more complex, a regular expression modifier may be necessary. In this example, the existing Print Command Script trigger files are printing to multiple printers: "Zebra (1)," "Zebra (2)," and "New Zebra." You want to redirect print jobs from only “Zebra (1)” and “Zebra (2)” to “Datamax”.

In this case, you can use regular expression modifiers to perform a more precise search.

ClosedTo add regular expression modifiers to a Search and Replace action

  1. In the Options section of the Search and Replace property tab, click Use Regular Expression in the Search Method list.

  2. In the Search for box, enter "Zebra".

  3. Place your cursor immediately after the letter "a".

  4. Click , and then click "." in the list of regular expression modifiers.

  5. Click again, and then click "*" in the list of regular expression modifiers.

The result is "Zebra.*" in the Search for box. This expression specifies the search term "Zebra" plus any characters that follow it until the ending quotation mark character is reached, as follows:

  • The "." character matches to any single character.

  • The "*" character matches zero or more times.

By combining "." and "*" into "Zebra.*", your search finds quotation mark plus Zebra plus any number of trailing characters until the ending quotation mark is reached. When those instances are found in the trigger file, they are replaced with “Datamax”.

ClosedExample: Wildcard Modifiers

You can use a wildcard character to substitute one or more characters in a string. The following procedure assumes the same scenario as was described in the previous example, but the Search and Replace action uses wildcard modifiers.

ClosedTo add wildcard modifiers to a Search and Replace action

  1. In the Options section of the Search and Replace property tab, click Use Wildcards (* and ?) in the Search Method list.

  2. In the Search for box, enter "Zebra".

  3. Place your cursor immediately after the letter "a".

  4. Click , and then click "?" in the list of wildcard modifiers.

  5. Click again, and then click "*" in the list of wildcard modifiers.

The result is "Zebra?*" in the Search for box. This specifies the search term "Zebra" plus any characters that follow it.

Searching with wildcards is not as powerful a method as searching with regular expressions. Searching with wildcards may not result in an equivalent match.