A regular expression is a pattern that describes a specific portion of text. Few Exchange Online Knowledge Scripts allows you to use regular expressions to define inclusion or exclusion filters for pattern-matching against the text being evaluated.
The following table lists some commonly used regular expression types and their usage.
For more information about regular expression syntax, see related Web sites such as www.wikipedia.org/wiki/Regular_expression or www.regular-expressions.info.
Regular Expression Type |
Description |
---|---|
Alternate Matches |
A pipe character, |, indicates alternate possibilities. For example:
|
Anchor |
Anchors do not match characters. Instead, they match a position before, after, or between characters. They anchor the regular expression match at a certain point.
|
Escape Metacharacter |
A backslash character, \, preceded with special characters such as ., @, |, *, ?, +, (, ), {, }, [, ], ^, $ and \ forces the special characters to be interpreted as normal characters. For example:
|
Literal |
A literal expression consists of a single character that matches all the occurrences of that character in the text string. For example, if the expression is a and the text string is The gray cat is purring, then the match is the a in gray and a in cat. All characters except for the following are literals: ., |, *, ?, +, (, ), {, }, [, ], ^, $ and \. These characters are treated as literals when preceded by a \. |
Matching Characters or Digits |
|
Parentheses |
Use parentheses, (), to group characters and then apply a repetition operator to the group. For example, the expression (ab)* returns all of the string ababab. |
Repeat |
A repeat is an expression that is repeated an arbitrary number of times.
|
Square Brackets |
Use square brackets, [], to match any one of the characters that is enclosed in the brackets. You can specify a range of characters by using a hyphen. For example, the expression [a-i] that performs the same match as [abcdefghi] returns all services that match any one of the characters inside the square brackets such as ‘a’ in “Azure Information Protection”, ‘e’ in “Exchange Online” and ‘i’ in “Identity Service” |
Wildcard |
The dot wildcard, .,matches any single character except line break characters. For example, the expression gr.y matches gray, grey, gr%y, and so on. |
Word Boundary |
|