javascript - How do the regular expressions in sizzle.js work? -


if escaped characters in regular expression created in javascript regexp object need escaped again how following code in sizzle.js work -

identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+" 

if \\\\\\\ = \ , \\\w = \w how \0 = \0 when single backslash used?

when run in google console identifier "(?:\\\\.|[\w-]|[^-\\xa0])+"

is mistake or not understanding correctly? if correct , how intended work purpose of \0?

if regular expression needs contain backslash — e.g., because need \( (which matches actual () or \w (which matches letter or digit or underscore) — , you're creating regular expression string literal, need write \\, ends \ in regular expression.

but in \0 example, regular expression doesn't need contain backslash. needs contain character u+0000 (which matches itself). string literal can contain \0, ends character u+0000.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -