Regex token xboxmusic api

35 Views Asked by At

I need to figure out where the error is in this regular expression with this pattern:

.*\"access_token\":\"(?<;token>,.*?)\".*

In the string where the search is made is

{"token_type":"http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0","access_token":"http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=xboxmusiceidos&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&Audience=http%3a%2f%2fmusic.xboxlive.com&ExpiresOn=1414161447&Issuer=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&HMACSHA256=RQYlusDkweAgvUNFK6%2fxWOY9S1IV5SOk8deMoLOvrzs%3d","expires_in":"599","scope":"http://music.xboxlive.com"}

The result should be the whole string after the keyword access_token to expires_in excluded:

http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=xboxmusiceidos&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&Audience=http%3a%2f%2fmusic.xboxlive.com&ExpiresOn=1414161447&Issuer=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&HMACSHA256=RQYlusDkweAgvUNFK6%2fxWOY9S1IV5SOk8deMoLOvrzs%3d
1

There are 1 best solutions below

0
On

Regular Expression: (?<=access\_token\"\:\").*(?=\"\,\"expires_in)

Your Lookahead and Lookbehind operators were not correct.