In my url, i'm suppose to get the token number, but the token number may be Numeric or Alpha. I need to get the token always in different scenario. How do I achieve that using Regular Expressions?
Sample URLs:
?&token=1905477219/someother/stuff
&token=1905477219
&token=xyzbacsfhsaof
&token=xyzbacsfhsaof/some/other
How can I always get the token from these kind of URLs?
I tried this:
/(token=.*)/g
I am looking for :
?&token=1905477219/someother/stuff - in this case "1905477219"
and
&token=xyzbacsfhsaof - in this case "xyzbacsfhsaof" .. like so
But it's not working. Can any one can help me?
Thanks all, this is working fine for me:
var reg = window.location.href.match(/token=([^\/]*)/)[1];