Regular Expressions

A regular expression is a text string that has special characters (meta characters) that is used to match patterns in another text strings.  In short regular expressions are used for string matching.  This is best illustrated with a simple example:

We want to determine if the word "rabbit" or the word "road" exit in the string:

"The rabbit ran down the road."

We can do this with the following regular expression string:

rabbit|road

Notice the vertical bar character between rabbit and road.  This is referred to as a meta character and it has the meaning of the or condition.

SmartBatch provides the capability to use regular expressions in several different areas of the product that are outlined below.  Some examples are provided that focus on typical uses of regular expressions in conjunction with SmartBatch.  A regular expression evaluator is provided in the SmartBatch product that helps you determine if you have the correct expression.  Please refer to Microsoft developer documentation (MSDN) for more in-depth documentation.  There are also many useful sites on the internet that provide regular expression examples.  To find these sites use a Google search on "Regular Expressions".  Further if you want specific help on a regular expression send email to: support@onlinetoolworks.com.  Explain in the email which regular expression field you are using and what you need to accomplish.

Regular expressions can be used in searches that are simple to very complex.  Regular expressions provides a language that can be used to accomplish this.  The UNIX environment has been accustom to regular expressions for many years as regular expressions have been implemented in products such as awk and Perl .  .NET has included native support for regular expressions making them easier to use.  Regular expressions are probably best understood using some examples.  The examples are presented in a set of scenarios that you may find useful:

Scenario 1 (simple match)

You need to determine if the keyword success exists in an application log file.

Regular expression:  success

If success is found anywhere in the file the regular expression will indicate the starting position of success in the file.

Scenario 2 (Or Condition)

Determine if the word error or failure exits in the application log file.

Regular expression:  error|failure

Scenario 3 (And Condition)

Determine if the word error and failure exists in the application log file.

Regular expression:  (error.+failure)

The "." (period) and the + (plus) characters are meta characters.  The period is a wildcard character indicating any character.  The plus character indicates that there must be at least one character (spaces count) between the words.

Scenario 4 (And Condition)

Determine if the word error and failure exists in the application log file and the words may appear in any order (that is, error may appear before failure or after failure in the file):

Regular expression:  (error.+failure)|(failure.error)

Scenario 5 (Or Condition)  

Determine if the exit code 0, 1 or 9 was returned from an Operation.

Regular expression:  0|1|9

Note that the "|" separating the 0, 1 and 9 are vertical bars.  These indicate that 0 or 1 or 9 are valid values.

Fields that support regular expression matching are documented throughout this document.  Refer to the specific field you are interested for more examples and specific information.  The following fields support regular expressions in SmartBatch:

The following table indicates the fields in SmartBatch that support regular expressions along with a link to the main section that documents the use of the field:

Field

Link

Application Log Expression

Operation Properties

Exit Code Expression

Operation Properties

Dependency File Expression

Dependency Properties

File Viewer Find

File Viewer

History Name Filter

History

Status Filter

Status