For single characters, alternates can be specified by square brackets with
-
[abc] meaning a or b or c
|
For general strings one can use | to represent alternatives or so that above example can also be written
-
a|b|c means a or b or c but this operator can be generalized to longer sequences so that 1995 CPS616 (first year this course was taught!) instructor can be written
-
Fox|Furmanski or if we can't spell Polish names
-
Fox|Furmansk(i|y|ie) # See later for use of parentheses
|
Patterns can be Anchored in four ways:
-
/^Keyname:/ matches to Keyname: ONLY if it starts string -- ^ only has this special meaning at start of regular expression
-
/Quit$/ matches Quit ONLY if it ends string -- $ only has this meaning if at end of regular expression
-
\b matches a word(PERL/C variable) boundary so that
-
/Variable\b/ matches Variable but not Variables ( inside [] construct, \b means a backspace as described in earlier table)
-
\B matches NOT a word boundary so that
-
/Variable\B/ matches Variables but not Variable
|