If I want to match the dot symbol (.
) I have to write this regex:
/\\./
Escape character is needed to match the
The .
character is a reserved regular expression keyword. The d
isn't. You need to include the escape character when you match a period to explicitly tell regex that you want to use the period as a normal matching character. d
by itself isn't a reserved word, so you don't need to escape it, but \d
is a reserved word.
I can see how, to someone coming to regex it can be a little odd, but the .
is used so often, and I can't think of a time I've really needed to match periods it just makes more sense to have it be one character without the backslash.