In my url, I intend to get the token number, but the token number can be Numeric or Alpha. I need to get the token always in a different scenario. How to achieve this with regular expressions?
Sample URLs:
?&token=1905477219/someother/stuff &token=1905477219 &token=xyzbacsfhsaof &token=xyzbacsfhsaof/some/other
How can I always get token from these urls?
I tried this:
/(token=.*)/g
I'm looking for:
?&token=1905477219/someother/stuff - in this case "1905477219"
and
&token=xyzbacsfhsaof - in this case "xyzbacsfhsaof" .. like this
But it does not work. Can anyone help me out?
Thanks everyone, this works great for me:
var reg = window.location.href.match(/token=([^\/]*)/)[1];
source share