A regular expression consists of a sequence of characters that must correspond to ones that appear in matched strings. Characters shown in the following table serve as regular expression operators
|
Regular Expression Operator |
Description |
Example |
|---|---|---|
|
. |
The dot operator represents any character except an end of line character. |
The expression a.b matches any string of three characters starting with “a” and ending with “b”. |
|
\ |
The escape enables the use of the operator as literal characters instead of being recognized as operators. If a mask is specified as a literal string in a CA Process Automation expression, the escape operator must itself be escaped to avoid having the escape character stripped by the CA Process Automation expression interpreter before the mask is passed to the regular expression parser.
|
The escaped character \\ matches the backslash character \. The escaped operator \| matches the vertical bar. For a literal string in a CA Process Automation expression, "\\?" matches the question mark.
|
|
\n |
End of line escape character sequence. If a mask is specified as a literal string in a CA Process Automation expression, the end of line escape character sequence must itself be escaped to avoid having the escape character stripped off by the CA Process Automation expression interpreter before the mask is passed to the regular expression parser. |
The expression first line\nsecond line matches strings where “first line” appears at the end of a line and “second line” appears at the start of the next line. If the same expression is specified by a literal string in a CA Process Automation expression, the operator is escaped as follows: "first line\\nsecond line" |
|
| |
Alternative. This operator creates an alternative between characters or groups. It applies to the character or groups immediately adjacent to it on its left or right. |
(a|b) matches the character “a” or the character “b”. (abcd)|(efgh) matches the string “abcd” or the string “efgh”. (ab|Bc) matches the string “abc” or the string “aBc”. |
|
( ) |
Group. This operator groups characters in a sub-expression that applies to alternative and repetition operators. |
(abcd)|(efgh) matches the string “abcd” or the string “efgh”. (abcde)* matches zero, one or several successive occurrences of the string “abcde”, whereas abcde* matches strings starting with “abcd” followed by an zero or more “e” characters. |
|
[ ] |
Used to define a class of characters by inclusion. It is composed of a list of individual characters and intervals (ranges). |
This construct matches a single character. [0-9] matches one digit. [aeiou] matches one vowel. [a-cx-z9] matches a letter among the first three and the last three characters of the alphabet or the digit 9. [0-9]+ matches an integer. [^] Used to define a class of characters by exclusion. This construct matches a single character. [^0-9] matches any character except a digit. [^aeiou] matches any character except a vowel. |
|
* |
Repetition. Defines zero or more occurrences of the character or group that appears next to the operator. The series can be empty. a* matches zero or more “a” characters. |
(123)* matches zero or more repetitions of the string “123”. 123* matches the digits 12 followed by zero or more “3” characters. |
|
+ |
Repetition. Defines one or more occurrences of the character or group that appears next to the operator. The series cannot be empty. |
a+ matches one or more “a” characters. (ab)+ matches a series one or more repetitions of the string “ab”. [a-z , |.] matches a series of words in small letters, separated by blanks, commas, or periods. |
|
? |
Used to indicate that the character or group preceding the operator is optional. ab?c matches the strings “abc” and “ac”. |
a(X|Y)?b matches strings “ab”, “aXb”, and “aYb”. |
|
{n} |
Used to define a precise number of repetitions of the character or group preceding the operator. |
[0-9]{,2} matches a number made of exactly two digits. (ab){2} matches the string “abab”. abc{2} matches the string “abcc”. (a{2})* matches the strings made of an even number of “a” characters. |
|
{n,m} |
Used to specify that the number of occurrences of the character or group preceding the operator is between n and m. |
[0-9]{2,3} matches a number made of two or three digits. (ab){1,2} matches the string “ab” or “abab”. |
|
{n,} |
Used to specify that the number of occurrences of the character or group preceding the operator is n or more. |
0-9]{2,} matches a number made of at least two digits. |
|
{,n} |
Used to specify that the number of occurrences of the character or group preceding the operator is n or fewer. |
[0-9]{,2} matches numbers equal to or less than 99, including the empty string. |
|
Copyright © 2014 CA.
All rights reserved.
|
|