Alternation, Expression anchors—restricting what patterns match, Table 10. regular expression anchors – Visara Master Console Center Scripting Guide User Manual
Page 62

Chapter 4 Regular Expressions
Scripting Guide
62
Alternation
If ’x’ and ‘y’ are REs, then ‘x|y’ is an RE matching any string that is
matched by either ‘x’ or ‘y’. For example, the RE “((cd)|e)b” matches the
string “cdb” and the string “eb”. Single characters or expressions
matching single characters, separated by the vertical bar and enclosed in
parentheses, match a single character.
Expression Anchors—Restricting What Patterns Match
The search pattern (an entire RE) can be anchored to restrict a match:
From the beginning of a line.
Up to the end of the line.
The entire line.
The following anchors restrict a search pattern:
Anchor Restriction
“^”
The circumflex placed at the beginning of an expression or
subexpression causes the pattern to match only a string
that begins in the first character position in a string . For
example, the pattern “^bc” matches bc in the string “bcdef”
but does not match bc in “abcdef”. The subexpression
“(^bc)” also matches bcdef.
“$”
The dollar sign placed at the end of a pattern causes the
pattern to match only if the last matched character is
the last character (not including the new line character)
in a string.
^pattern$
The construction ^pattern$ restricts the pattern to
matching only an entire string. For example, the RE
“^abcd$” matches strings containing the string “abcd”,
where ‘a’ is the first character in the string and ‘d’ the last.
Table 10. Regular Expression Anchors