We know that . matches any character, [ and ] are used for character classes, { and } are used for limiting quantifiers, and ? , *, and + are used for various quantifiers. To match any of the metacharacters literally, one needs to escape these characters using a backslash ( ) to suppress their special meaning. Similarly, ^ and $ are anchors that are also considered regex metacharacters.
Let's see some examples of escaping metacharacters in regular expressions.
The following regex matches the string, a.b?:
a.b?
The following regex matches the string, {food}:
{food}
The following regex matches the string, abc:][}{:
abc:][}{
The following regex matches the string, $25.50:
$d+.d+
The following regex matches the string, ^*+.:
^*+.