javascript - Url parameters extraction -
var results = new regexp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
could u please explain exactlly happening in above line of code.
thanks in advance.
- you create variable name of
results
scoped execution context. - you invoke
regexp
constructor thereby instantiating object , pass string used regex. have way because can't concatenate regex literals outside data. - the regex says match of
\
,?
or&
followedname
variable, , literal=
, make capturing group of every character besides&
or#
, 0 or more times. - you call
exec()
method on newregexp
object,window.location.href
(the current url) argument. - the return of assigned
results
variable. - the capturing group's contents (if successful) in
results[1]
.
or
you getting param name :)
Comments
Post a Comment