Parent Topic

Searching for a Record

Previous Topic

Next Topic

Book Contents

Book Index

Using Regular Expressions for Searching

When searching for an existing record, if a value is entered into a field, the system automatically displays all records that BEGIN WITH a matching value for that field.

However, when searching for a record, sometimes the user is not sure of the exact name of the field value. Regular Expressions can be used to expand the search to include records that have the entered value WITHIN the field, or to limit the search to return records that contain ONLY the entered values.

The following Reserved Characters are used with Regular Expression Searches:

.

This symbol indicates a single character preceding the value entered in the field. When using other regular expressions indicating preceding characters, this symbol must also be used. See Example 2 below.

*

This symbol indicates a wild card for any number of previous characters. For example, .*RN would display all records that contain RN within the field value. See Example 3 below.

$

This symbol is used to indicate the ending value of a string, or an EXACT MATCH. When the symbol is placed after a value, there cannot be any other characters after the field value. For example, D$ indicates the value must end with D. Since there are no wild card symbols in front of D, this indicates an exact match. See Example 4 below.

^

This symbol is used to indicate the beginning value of a string. This can be used with a search string combining other reserved characters, since the search results already include all values that begin with the entered value by default.

|

This symbol works like an OR operator. For example, hi|hello matches a string that has either "hi" or "hello" in it.

See Example 5 below.

Combining Multiple Symbols in an Advanced Search Expression:

Multiple symbols can be combined to indicate a regular expression with different variables. For example, entering *.Manager$ will display all records that begin with any characters, but must end with Manager. The previous character symbol (.) and wild card symbol (*) at the beginning of the expression indicate any number of characters can be in front of the word Manager. The ending symbol ($) in the expression indicates the value must end with the word Manager. See Example 5 below.

Using Reserved Characters as "Common" Characters When Searching for a Record:

When searching for a field value that contains one of the reserved characters used with regular expressions, you must prefix the character with a backslash \ . The following are reserved characters: . $ ^ { [ ( | ) * + ?

In the example below, the user is searching for an activity code D$. If the user enters D$ in the Code field, only D activity codes are displayed. That is because the dollar sign is a reserved character used in regular expressions to indicate the ending value of a field, or an exact match. When the $ symbol is placed after a value, there cannot be any other characters after the field value. So entered this way, D$ indicates the value must end with D.

To indicate that the dollar sign is to be used as a common character and not a reserved character, the backslash symbol \ must be entered before the dollar sign. For example, enter D\$ to indicate you are searching for the activity code D$.

If reserved characters are used in a search field, but the value entered does not follow the basic syntax of Regular Expressions, an error message is generated. In the example below, a single parenthesis is entered, and the system is looking for the matching parenthesis.

Example 1 - No Regular Expressions

When no regular expressions are used, all records that BEGIN with the entered value are displayed. For example, if you enter d for an activity code search, all codes that start with d (such as D8, D10, and D12) are returned.

Example 2 - Single Preceding Character Search

When the period symbol (.) is used, the result set includes all records with a single character preceding the entered value. For example, if you enter .d for an organization unit search, all codes with the second letter of d (such as Admin and Education) are returned.

Example 3 - Symbol for a Wild Card Search

When the wild card symbol (*) is used, the previous value can be repeated any number (zero or more) of times. It may be used with any character, but the most common use of this is to use a period (.) special character with this symbol to represent any number of any characters. For example, if you enter .*manager in the Description field for an organization unit search, all units that have something preceding manager (such as Facilities Manager) are returned.

Example 4 - Ends With (or Exact Match) Search

When the dollar symbol ($) is used, the entered value can only be at the end of the entry. When this symbol is used without any other search symbols, this requires an exact match. For example, if you enter d$ for an activity code search, only the codes that match (such as D, but not Day, D8, D10, or D12) are returned.

Example 5 - OR Operator Search

Enter the bar symbol (|) to indicate the field can contain either one or the other of the values entered. For example, if you enter day|night for an activity code search, all codes containing day or night are returned.

Example 6 - Combining Search Symbols

The previous character symbol (.) and wild card symbol (*) at the beginning of the expression indicates any number of characters can be in front of the included word. The ending symbol ($) in the expression indicates the value must end with the included word. For example, if you enter .*manager$ in the Description field for a job class search, all job classes that end with manager (such as Finance Manager and Nursing Manager) are returned.

Additional Regular Expressions for Searching

The following are some additional examples of Basic Syntax of Regular Expressions that can be used for searching in the system (e.g. employee search or indicator search).

^The : matches any string that starts with "The";

of despair$ : matches a string that ends in the substring "of despair";

notice : a string that has the text "notice" in it.

ab* : matches a string that has an "a" followed by zero or more b's ("a", "ab", "abbb", etc.);

ab+ : same, but there's at least one "b" ("ab", "abbb", etc.);

ab? : there might be a "b" or not;

a?b+$ : a possible"a" followed by one or more b's ending a string.

ab{2} : matches a string that has an "a" followed by exactly two "b's" ("abb");

ab{2,} : there are at least two "b's" ("abb", "abbbb", etc.);

ab{3,5} : from three to five "b's" ("abbb", "abbbb", or "abbbbb").

a(bc)* : matches a string that has an a followed by zero or more copies of the sequence "bc";

a(bc){1,5} : one through five copies of "bc."

hi|hello : matches a string that has either "hi" or "hello" in it;

(b|cd)ef : a string that has either "bef" or "cdef";

(a|b)*c : a string that has a sequence of alternating a's and b's ending in a c;

A period ('.') stands for any single character:

a.[0-9] : matches a string that has an "a" followed by one character and a digit;

^.{3}$ : a string with exactly 3 characters.

[ab] : matches a string that has either an "a" or a "b" (that's the same as "a|b");

[a-d] : a string that has lowercase letters "a" through "d" (that's equal to "a|b|c|d" and even "[abcd]");

^[a-zA-Z] : a string that starts with a letter;

[0-9]% : a string that has a single digit before a percent sign