So, what do we do if we need to match a literal question mark, star, plus, pipe, square bracket,
or other metacharacter?
Easy - like many other languages, we use an escape character to let the regex engine know that
the next character is a literal. For example:
\?
\*
\+
\]
\[
\|
will let us match the corresponding literal character.
Some tools have variations on what is a literal and what is a metacharacter, and we have to
be careful with these. Remember I said that I lied about the brackets for grouping?
grep, GNU Emacs and vi all count round brackets as literal characters by default, so
if we want to use brackets for grouping (i.e. use brackets as a metacharacter, or, more
correctly in this case, a metasequence) then we need to escape them:
\(
\)
Other tools will also allow the use of octals and hexadecimals in regular expressions
with: