Eshi Eshi - 10 months ago 79
JSON Question

JMeter: How to use Regular Expression to extract the value of a duplicate field?

I have the following Response Body JSON:

"address": [
"id": "1234"
"id": "d1a4f010-48d9-434b-9b3a-2d2b12f5e38c"

I am trying to extract the value of the the second "id" field, i.e.

"id": "d1a4f010-48d9-434b-9b3a-2d2b12f5e38c"

I use this Regular Expression in JMeter:
Regular Expression: "id":"(.+?)"

When I run my test, it returns "1234" instead of the guid. How can I change my Regular Expression so that it returns the guid?

Answer Source

You can use a lazy regex to find the guid directly instead of finding "id"

Something like this: ([0-9a-z-]{36}).*?

If you are not sure how to create the regex, just use an online regex maker. Hope it helps!