Escape dot in a regex range
Solution 1:
The dot operator .
does not need to be escaped inside of a character class []
.
Solution 2:
Because the dot is inside character class (square brackets []
).
Take a look at http://www.regular-expressions.info/reference.html, it says (under char class section):
Any character except ^-]\ add that character to the possible matches for the character class.
Solution 3:
If you using JavaScript to test your Regex, try \\.
instead of \.
.
It acts on the same way because JS remove first backslash.
Solution 4:
On this web page, I see that:
"Remember that the dot is not a metacharacter inside a character class, so we do not need to escape it with a backslash."
So I guess the escaping of it is unnecessary...