Thursday, 12 September 2013

Javascript pull data from string?

Javascript pull data from string?

I have a long URL that contains some data that I need to pull. I am able
to get the end of the URL by doing this:
var data = window.location.hash;
When I do alert(data); I receive a long string like this:
#access_token=0u2389ruq892hqjru3h289r3u892ru3892r32235423&token_type=Bearer&expires_in=3600
note in the example the access token is not valid, just random numbers I
input for example purpose
Now that I have that long string stored in a variable, how can I parse out
just the access token value, so everything in between the first '=' and
'&. So this is what I need out of the string:
0u2389ruq892hqjru3h289r3u892ru3892r32235423
I was reading up on php explode, and others java script specific stuff
like strip but couldn't get them to function as needed. Thanks guys.

No comments:

Post a Comment