1
votes

I have multiple string of grp and name in the response message. I want to extract the grp based on unique name ,"grp":(.+?),"name":"UNIQUE_STRING"

Regular Expression Extractor Reference Name: group_name Regular

Expression: "grp":(.+?),"name":"UNIQUE_STRING" Template : $1$ Match no: 1

I want to extract the preceding value based on the unique name but not able to find.. Please help

2
Can you give example of response message?user7294900
"grp":11111,"name":"test_constant1","target":{"abc","id":1,"id":1,"adminUser":{"id":2},"owner":{"text":"test","name":"TEST"},"targetSystemSource":null}}}],"grp":22222,"name":"test_constant2" Here based on second name test_constant2 i want to find correspond grp which is 22222. is it posible from regx post processor?Nikhil

2 Answers

0
votes

You can find string until the first comma:

Regular Expression: grp":([^,]+),"name":"UNIQUE_STRING

If you want to remove " in grp value (find 123 for grp":"123") use:

Regular Expression: grp":"([^,]+)","name":"UNIQUE_STRING
0
votes

Your response is utterly like to be a JSON, if this is the case I believe it will be much easier to use JSON Extractor (available since JMeter 3.0)

If your response data looks something like:

[
  {
    "grp": "foo",
    "name": "UNIQUE_STRING"
  },
  {
    "grp": "bar",
    "name": "ANOTHER_STRING"
  }
]

You should be able to extract this foo value using a simple Json Path query like: $..[?(@.name == 'UNIQUE_STRING')].grp

Demo:

JMeter JSONPath Conditional Select

More information: JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios