Service Development Help : Regular Expressions : Regular Expression Operators
Regular Expression Operators
Following are the operators supported in the webMethods implementation of regular expressions.
Use this symbol…
To…
.
Match any single character except a new line.
Example  doc.p[/web.ethods/].text
This example would return any paragraph containing the string ‘web’ followed by any single character and the string ‘ethods’. It would match both ‘webMethods’ and ‘webmethods’.
^
Match the beginning of the string or line.
Example  doc.p[/^webMethods/].text
This example would return any paragraph containing the string ‘webMethods’ at the beginning of the element or at the beginning of any line within that element.
$
Match the end of the string or line.
Example  doc.p[/webMethods$/].text
This example would return any paragraph containing the string ‘webMethods’ at the end of the paragraph element or at the end of any line within that element.
*
Match the preceding item zero or more times.
Example doc.p[/part *555-A/].text
This example would return any paragraph containing the string ‘part’ followed by zero or more spaces and then the characters ‘555-A’.
+
Match the preceding item 1 or more times.
Example doc.p[/part +555-A/].text
This example would return any paragraph containing the string ‘part’ followed by one or more spaces and then the characters ‘555-A’.
?
Match the preceding item 0 or 1 times.
Example doc.p[/part ?555-A/].text
This example would return any paragraph containing the string ‘part’ followed by zero or one space and then the characters ‘555-A’.
( )
When used in an index, these characters group an item within the regular expression.
Example  doc.p[/part(,0)+May/].text
This example would return any paragraph containing the string ‘part’ followed by one or more occurrences of the characters ‘,0’ and then the characters ‘May’.
When used in a mask, they specify characters that you want to retain.
Example  doc.p[].text[(^.{25}).*]
This example would keep the first 25 characters within each paragraph and discard the rest.
{n }
Match the preceding item exactly n times.
Example  doc.p[/^.{24}webmethods/].text
This example would return any paragraph in which the word ‘webmethods’ started in the 25th character position of the paragraph.
{n ,}
Match the preceding item n or more times.
Example  doc.p[/^.{10,}webmethods/].text
This example would return any paragraph in which the word ‘webmethods’ appeared anywhere after the 10th character position of the paragraph. That is, this example would return a paragraph in which the word ‘webmethods’ started in the 11th or later character position of the paragraph.
{0,m}
Match the preceding item none or at most m times.
Example  doc.p[/^.{1,4}webmethods/].text
This example would return any paragraph in which the word ‘webmethods’ started in character position 2 through 5 of the paragraph.
|
Match the expression that precedes or follows this character.
Example  doc.p[/webmethods|webMethods/].text
This example would return any paragraph that contained either ‘webmethods’ or ‘webMethods’.
\b
Match a word boundary.
Example  doc.p[/\bport\b/].text
This example would return any paragraph that contained the word ‘port’, but not paragraphs that contained these characters as part of a larger word, such as ‘import’, ‘support’, ‘ports’ or ‘ported’.
\B
Match a boundary that is not a word boundary.
Example doc.p[/\B555-A/].text
This example would return any paragraph that contained the characters ‘555-A’ as part of a larger word such as AZ555-A, or Dept555-A, but not ‘555-A’ alone.
\A
Match only at the beginning of a string.
Example  doc.p[/\AwebMethods/].text
This example would return any paragraph containing the string ‘webMethods’ at the beginning of the element or at the beginning of any line within that element.
\Z
Match only at the end of a string (or before a new line at the end).
Example  doc.p[/webMethods\Z/].text
This example would return any paragraph containing the string ‘webMethods’ at the end of the paragraph element or at the end of any line within that element.
\n
Match a new line.
Example  doc.p[/webMethods\n/].text
This example would return any paragraph containing the string ‘webMethods’ followed by the new line character.
\r
Match a carriage return.
Example  doc.p[/webMethods\r/].text
This example would return any paragraph containing the string ‘webMethods’ followed by a carriage return.
\t
Match a tab character.
Example  doc.p[/\twebMethods/].text
This example would return any paragraph containing the string ‘webMethods’ preceded by a tab character.
\f
Match a form feed character.
Example  doc.p[/webMethods\f/].text
This example would return any paragraph containing the string ‘webMethods’ followed by a form feed character.
\d
Match any digit. Same as [0-9].
Example doc.p[/part \d555-A/].text
This example would return any paragraph containing a part number that starts with any digit 0 through 9, and is followed by the characters 555-A. Therefore, it would match ‘part 1555-A’ but not ‘part A555-A’ or ‘part #555-A’.
\D
Match any non-digit. Same as [^0-9].
Example doc.p[/part \D555-A/].text
This example would return any paragraph containing a part number that starts with any character other than 0 through 9, and is followed by the characters 555-A. Therefore, it would match ‘part A555-A’ and ‘part #555-A’, but not ‘part 1555-A’.
\w
Match any word character. Same as [0-9a-z_A-Z].
Example doc.p[/part \w4555-A/].text
This example would return any paragraph containing a part number that starts with a letter or digit and is followed by the characters 555-A. Therefore, it would match ‘part A555-A’ and ‘part 1555-A’, but not ‘part #555-A’.
\W
Match any nonword character. Same as [^0-9a-z_A-Z].
Example doc.p[/part \W4555-A/].text
This example would return any paragraph containing a part number that starts with a character other than a letter or digit, and is followed by the characters 555-A. Therefore, it would match ‘part #555-A’ and ‘part -555-A’, but not ‘part 1555-A’ or ‘part A555-A’.
\s
Match any white-space character. Same as [\t\n\r\f].
Example doc.p[/\swebMethods/].text
This example would return any paragraph containing the string ‘webMethods’ if it is preceded by a tab character, a new line character, a carriage return, or a form-feed character.
\S
Match any nonwhite-space character. Same as [^\t\n\r\f].
Example doc.p[/\SwebMethods/].text
This example would return any paragraph containing the string ‘webMethods’, if that string is not preceded by a tab character, a new line character, a carriage return, or a form-feed character.
\0
Match a null string.
Example  doc.p[/[^\0]/].text
This example would return any paragraph that is not empty (null).
\xnn
Match any character with the hexadecimal value nn.
Example  doc.p[/\x1FwebMethods/].text
This example would return any paragraph containing the ASCII unit-separator character (1F) followed by the characters ‘webMethods’.
This example would return any paragraph containing the ASCII unit-separator character (1F) followed by the characters ‘webMethods’.
[ ]
Match any character within the brackets.
Example doc.p[/part [023]555-A/].text
This example would return any paragraph containing a part number that starts with the numbers 0, 2, or 3 and is followed by the characters 555-A. Therefore, it would match ‘part 0555-A’ and ‘part 2555-A’, but not ‘part 4555-A’.
The following characters have special meaning when used within brackets:
number that starts with the numbers 0, 2, or 3 and is followed by the characters 555-A. Therefore, it would match ‘part 0555-A’ and ‘part 2555-A’, but not ‘part 4555-A’.
The following characters have special meaning when used within brackets:
Use this char…
To…
^
Exclude characters from the pattern.
Example  doc.p[/part [^023]555-A/].text
This example would return any paragraph containing a part number that does not start with the numbers 0, 2, or 3, but is followed by the characters 555-A. Therefore, it would match ‘part 4555-A’ and ‘part A555-A’, but not ‘part 0555-A’.
-
Specify a range of allowed characters.
Example  doc.p[/part [A-M]555-A/].text
This example would return any paragraph containing a part number that starts with any letter A through M and is followed by the characters 555-A. Therefore, it would match ‘part A555-A’ and ‘part J555-A’, but not ‘part N555-A’.
Copyright © 2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback