0
votes

My Json response is:

"return":"/info?booking=KD6YGS4L8I"

Now I want to extract value after "=" (ex:"KD6YGS4L8I"). I used Regular Expression extractor: - Regular Expression: "return":"(.+?)" - Template: $1$ - Match No: -1

And output is:

"return":"/info?booking=KD6YGS4L8I"

Now I want to get string KD6YGS4L8I.

2

2 Answers

1
votes

You can use the following regular expression: booking=(.+?)", with template $1$. Match Number (n) depends on your needs:

  • n > 0: matches the given occurence number,
  • n == 0: matches a random occurence,
  • n < 0: matches all occurences, and organizes them with subvariables.

See Regular Expression Extractor on JMeter website.

I suggest you to take a look at the following guides:

0
votes

Add a Beanshell sampler as a sibling to your Regular Expression Extractor with the below code:

//Assuming your regular expression extractor variable is RegExpResult

String regExpResponse= ${RegExpResult};
String[] result= regExpResponse.split("=");
result[1].replaceAll("\"", "");
vars.put("BookingValue",result[1]);

Now BookingValue variable contains - KD6YGS4L8I

You can find the same issue been resolved in stackoverflow: JMeter - using substring on a user variable

Hope this helps! :)