this url
"?route=system/template/update&template_id=22&token=200bfaa1f5d6cda4c782f98b15f32e7f"
and i just need the token out of it
200bfaa1f5d6cda4c782f98b15f32e7f
how is the best way to parse that out...it seems to always be last
This should do it:
var
input = "?route=system/template/update&template_id=22&token=200bfaa1f5d6cda4c782f98b15f32e7f",
output = input.split("=").splice(-1)[0]; // output === "200bfaa1f5d6cda4c782f98b15f32e7f"
Or, if you're not sure that the token is always the last value:
var
input = "?route=system/template/update&template_id=22&token=200bfaa1f5d6cda4c782f98b15f32e7f&foo=bar&baz=spam",
output = input.substring(input.indexOf('token=')).split(/[=&]/)[1]; // output === "200bfaa1f5d6cda4c782f98b15f32e7f"
Or use regular expression. In this case it will be like
Format
var re = /token\=(\S+)/i;
alert(url.match(re)[1]);
&otherthing=123at the end, some may not work, maybe a clarification would help.