Patterns can be anchored in four ways:
-
/^regex/ matches regex at the beginning of the string only -- ^ has this special meaning only at the start of the regular expression
-
/regex$/ matches regex at the end of the string only -- $ has this meaning only at the end of the regular expression
-
\b matches a word boundary so that
-
/Variable\b/ matches Variable but not Variables (in a character class, \b denotes a backspace)
-
\B matches NOT a word boundary so that
-
/Variable\B/ matches Variables but not Variable
|