javascript - Correct way to match path inside a URL? (8) -
derived javascript, parts, regex matching urls.
pseudo code (each number represents sub-expression)
/^(1)(2)(3)(4)(5)(6)(7)$/
in 5 spot regex other things.
[^?#]*
pretty simple, not character class, match except ?
or #
, these later used match query , fragment identifier.
however, want replace character class not use not - ^
the first thing not sure of whether or not unicode can used in path. if can't planning on using ascii character set.
clarification: don't want use negative ahead emulates not character set.
reference: here complete regex broken different lines each part.
/^ (?:([a-za-z]+):)? (\/{0,3}) ([a-za-z0-9.\-]+) (?::(\d+))? (?:\/([^#?]*))? (?:\?([^#]))? (?:#(.*))? $/
the code points allowed ascii alpha numeric , described in url spec.
the url code points ascii alphanumeric, "!", "$", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", ":", ";", "=", "?", "@", "_", "~", , code points in ranges u+00a0 u+d7ff, u+e000 u+fdcf, u+fdf0 u+ffef, u+10000 u+1fffd, u+20000 u+2fffd, u+30000 u+3fffd, u+40000 u+4fffd, u+50000 u+5fffd, u+60000 u+6fffd, u+70000 u+7fffd, u+80000 u+8fffd, u+90000 u+9fffd, u+a0000 u+afffd, u+b0000 u+bfffd, u+c0000 u+cfffd, u+d0000 u+dfffd, u+e1000 u+efffd, u+f0000 u+ffffd, u+100000 u+10fffd.
further reference w3 available here:
Comments
Post a Comment