Another Regex example of extracting a parameter value from the Response Body

Hi -

I see examples of using Regex in Gatling to extract parameters from a Response Body, but I still cannot get my script to work.

Here is part of the response body (caution, quite a mess):

var oktaData = {“redirectUri”:“https\x3A\x2F\x2Fsso\x2Dcert.johndeere.com\x2Fapp\x2Fjohndeerecert_dealerpathcert_1\x2Fexkcj9qb4cfudNvLR1t7\x2Fsso\x2Fsaml”,“isMobileSso”:false,“isAppBannerVisible”:true,“fromUri”:"\x2Fapp\x2Fjohndeerecert_dealerpathcert_1\x2Fexkcj9qb4cfudNvLR1t7\x2Fsso\x2Fsaml",“isMobileClientLogin”:false,“requestContext”:{“target”:{“name”:“johndeerecert_dealerpathcert_1”,“links”:{“logo”:{“name”:“medium”,“href”:“https://ok4static.oktacdn.com/assets/img/logos/default.6770228fb0dab49a1695ef440a5279bb.png",“type”:“image/png”}},“label”:“Dealerpath_Cert”,“type”:{}},“authentication”:{“request”:{},“protocol”:{},“amr”:[],“issuer”:{“name”:“Dealerpath_Cert”,“id”:“0oacj9qb4dMjbwpwd1t7”,“uri”:“http://www.okta.com/exkcj9qb4cfudNvLR1t7”}}},“signIn”:{“logoText”:"\x20John\x20Deere\x20\x28CERT\x29\x20logo",“language”:“en”,“i18n”:{“en”:{“primaryauth.username.tooltip”:“This\x20is\x20your\x20internal\x20userid”,“account.unlock.email.or.username.placeholder”:“Email\x20or\x20Username”,“forgotpassword”:“Forgot\x20password\x3F”,“mfa.challenge.password.placeholder”:“Password”,“help”:“Help”,“password.forgot.email.or.username.tooltip”:“Email\x20or\x20Username”,“needhelp”:“Need\x20help\x20signing\x20in\x3F”,“primaryauth.username.placeholder”:“User\x20Name”,“password.forgot.email.or.username.placeholder”:“Email\x20or\x20Username”,“account.unlock.email.or.username.tooltip”:“Email\x20or\x20Username”,“unlockaccount”:“Unlock\x20account\x3F”,“primaryauth.password.placeholder”:“Password”,“primaryauth.title”:“Sign\x20In”}},“relayState”:"\x2Fapp\x2Fjohndeerecert_dealerpathcert_1\x2Fexkcj9qb4cfudNvLR1t7\x2Fsso\x2Fsaml",“features”:{“emailRecovery”:true,“restrictRedirectToForeground”:false,“hideDefaultTip”:true,“deviceFingerprinting”:true,“consent”:false,“useDeviceFingerprintForSecurityImage”:true,“router”:true,“showPasswordToggleOnSignInPage”:false,“securityImage”:false,“autoPush”:true,“smsRecovery”:false,“idpDiscovery”:false,“selfServiceUnlock”:false,“webauthn”:true,“registration”:false,“rememberMe”:true,“callRecovery”:false,“multiOptionalFactorEnroll”:true,“windowsVerify”:true},“baseUrl”:“https\x3A\x2F\x2Fsso\x2Dcert.johndeere.com”,“helpSupportNumber”:“309\x2D765\x2D0055”,“assets”:{“baseUrl”:"\x2F\x2Fok4static.oktacdn.com\x2Fassets\x2Fjs\x2Fmvc\x2Floginpage\x2Fjs\x2Fsdk\x2Fokta\x2Dsignin\x2Dwidget"},“customButtons”:[],“idpDiscovery”:{“requestContext”:"\x2Fapp\x2Fjohndeerecert_dealerpathcert_1\x2Fexkcj9qb4cfudNvLR1t7\x2Fsso\x2Fsaml"},“logo”:“https\x3A\x2F\x2Fok4static.oktacdn.com\x2Ffs\x2Fbco\x2F1\x2Ffs03wi2uzjmNQZfqh1t7”,“stateToken”:"00\x2DRwkGSBiTLxHyQhQg2zixt_IKOz1OaQBi0Gbhm08”,“helpLinks”:{“help”:“https\x3A\x2F\x2Fmyjohndeere.deere.com\x2Fwps\x2Fmyjd\x2Fen_US\x2Fmyjohndeere\x2Fhelp_signing_in.page”,“forgotPassword”:“https\x3A\x2F\x2Fforgotpass\x2Dcert.johndeere.com\x2Fui\x2Frecovery\x2Fpassword”,“unlock”:"",“custom”:[{“text”:“Concerned about the authenticity of this site? Contact your local IT Integrator or the Global IT Service Desk”,“href”:“http://servicedesk.deere.com/"}]},“piv”:{}},“accountChooserDiscoveryUrl”:“https\x3A\x2F\x2Flogin.okta.com\x2Fdiscovery\x2Fiframe.html”,“publishToAccountChooser”:true,"enableUrlFixForEmbeddedBrowsers”:false};

All I need to grab is the stateToken, highlighted in yellow.

I have explored some Regex, and here is what I currently am trying:

.check(regex(""“stateToken\”:\”(.+?)”,"""").findAll.optional.saveAs(“MyToken”))

Remove your backslashes, that’s the whole point of wrapping with triple double quotes.