I've looked at Prototype.js code and I saw there ( at the Sizzle part) :
My question is about that line :
CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
the \.
is for dot ,
next is (uncaptured group with : words, range and -
) OR (\.
). ( actually it says \\.
but the first one is just for escaping so it's \.
).
Huh ?
What's \.
?
I did test /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/.test('.aa\.')
and it returns true
.
But what is .aa\.
? obviously the class is .aa
but if \
is a valid char , why it isn't at the [..]
section ?
What am I missing ?
\\.
matches a literal backslash, followed by any character (the dot is not escaped).
From http://Sizzlejs.com/:
Escaped selector support #id\:value
It is used to match classes like a\~b
, and it is actually repeated in most selectors on your screenshots. It is common usually when you have dots or brackets in names or classes.
As for your test:
"\." === "."
, and your test is the same as .test('.aa.')
..test
allows partial matching - /\w+/.test("a!") === true
- it doesn't mean the last dot was actually matched.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With