I would like to know how I use the regex in Jmeter to capture tokens from HTML. I have created a regex but it's not getting what I required.

My HTML code with the token is :

<html><head></head><body><script type="text/javascript">    fetch("../../cookie", {        method: "POST",        mode: "cors",        cache: "no-cache",        credentials: "include",        headers: {            "Content-Type": "application/json",        },        redirect: "follow",        referrerPolicy: "no-referrer",        body: JSON.stringify({ token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzeXN0ZW1pZCI6Im5pcnZhbmEtZGlyZWN0LW5hLXFhMyIsInBpZCI6IjE2NTgwMzQ5MjE4NjgtMUpyM3hhdHNHNElvQkgxNHBWOXZhNiIsImxhdW5jaGlkIjoiNExSRXBBUFFJMkFPN3ZwbUFwazd1MiIsImlhdCI6MTY1ODAzNDkyMywiZXhwIjoxNjU4MDM0OTgzLCJpc3MiOiJQU0kifQ.DjYRQHoPeax9toiE0aC0l2af4DZbSwLNuySrnytDq-I" }),    }).then((response) => {  if (!response.ok) throw new Error(response.statusText);     document.location.href = "../../../index.html";    }).catch((error) => {    console.log(`error: ${error}`);    });</script></body></html>

In need to extract the value in between double quotes of token.

The tried regex is : token: "[^"]*

I won't require token text in this.

1 Answer 1


The correct regular expression would be something like:



  • \s* - optional number of whitespaces
  • () - grouping
  • . - any character
  • + - repetition
  • ? - don't be "greedy", stop at the first match


enter image description here

More information:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.