|
Match One of Alternate Literal Strings ( ( | ) )You can put a set of literal strings, each separated by a pipe bar (|), between parentheses. The string matches if it contains any one of the alternate literal strings.
Many special characters and literal characters can be mixed together to form a regular expression. Really long, complex regular expressions can be built to match any conceivable string. A special character is sometimes part of a literal string. If you want to include special characters in a regular expression to be treated as literal characters, you insert a backslash ( \ ) in front of the special character. For example, look at the following two regular expressions: ^.$ ^\.$ The first pattern matches a line that has one character on it, any character. The second expression matches a line that has one dot on it. The \ in front of the dot makes it into a literal dot, rather than a special character that represents any one character. Using a \ in front of a special character is called escaping the character. If you need to use a \ as a literal character, you would include \\ in the regular expression. |
|