The backslash in a regular expression precedes a literal character. You also escape certain letters that represent common character classes, such as \w for a word character or \s for a space. The following example matches word characters (alphanumeric and underscores) and spaces.
Regex(
"Are you there, Alice?, asked Jerry.", // source
"(here|there).+(\w+).+(said|asked)(\s)(\w+)\." ); // regular expression
"there, Alice?, asked Jerry."
(here|there).+ |
|
(\w+) |
|
.+
|
|
(said|asked)(\s)
|
|
(\w+)\.
|
\\ |
|
\A |
|
\b |
|
\B |
|
\cX |
|
\d |
single digit [0-9]
|
\D |
|
\E |
|
\l |
|
\L |
|
\Q |
|
\r |
|
\s |
|
\S |
|
\u |
|
\U |
|
\w |
word character [a-zA-Z0-9_]
|
\W |
single character that is NOT a word character [^a-zA-Z0-9_]
|
\x00-\xFF |
|
\x{0000}-\x{FFFF} |
|
\Z |