Need to extract all the values found in the response for a particular ReGex

98 views Asked by At

I have to extract all the contactIDs from the response using Jmeter. I am using the regex - "contactId":"(.+?)", but not able to figure out how we can extract all the contact IDS and save it in a file as it searches for particular match count. I've tried with match count as "-1" as well but it didn't work for me.

enter image description here

Can anyone suggest me how I can extract all the contact IDs and save in a file?

{"draw":2,"pageNumber":1,"recordsTotal":231,"recordsFiltered":231,"data":[{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"S3FWTmJ1MUNjMVRURXgzVU4rSHFNYW9vaDlrNVFHQ0t3VDBNUzBjSndrMGo0RFlGMExmeVZRMHFvcHZoNEIxZQ==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"OGRKVDZoT25HZldRUDRlQkZOdGw5c3h4RGE4YXlzQXpyUzF0eWlaeXlJUkdESHFydmdRd1ByQTZqYm5DbjZmSg==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":0},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"WmdTeUtiUTg0dmd1dUpjL21Cbzk2c2dmMlNBb3RhU3FpNFlTTzhCQ0dlZkdWaUJpMVlpTm5GMG9mSytaWDhWNg==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"c3VHS3hYRjZ3WVhpbU1UOHF1bGtPNG0zOFp4SmZWdWdjTlpzYlltaGZLK04ySldNeFlrVnJaNVNRN3l0M0ljVg==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"M2ZPdEFMTFNhMzFqYzhjaGt2b2hYZEl2d2kvWm5VYmtZTWRkSnZvL2xFMGtzUHpKQkpGT3VTQXJWaFR0M09KWg==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"ZytuTzZwd293RUZpazh2aXZxQWRMcHdHeDBYT1UvaXJVdmswTHhCczZDZG1aZkRmOCtRdUgrNTlxWC9xaHIzRA==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"Z1M4Ni8ybGZVYURtZ3hZczJxZkhIT1E3L3NZYklYRXZJdmh1YngvSjhkTmJPd3hvcElDR05DckljeGZpeVkwNg==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"VUFOL0V6Q3lzWDZWTm9MRHRpSTFNRWJqYUNrQ2xobWZ0VWlRUExHT3p5dzh0YkFuMnBUNllScWFNTkQ5d3dwVQ==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"MjBvN1JGRERaUDlqM1YrVHM0N0EzVzlGZVk5SHV4cnVSUXQzMjJzd0RqS0UxMUtqdXlibU45V0huRUNhRFFEbw==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"elMrRHdWNkFJTjlSdUhEY1A0d1FwN3JvS1E5MGVsSFZNTkNwSmVWL01Bcm90a3dXKzhMQU9SVjRoWFExUCtpdQ==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"OUxLM2FqUXZ4dWlGZVBGTjhiY0tOek03WW0wK1FMQ01IRzFCTmIrNU9hcFdUTWpTRFp6S3RIdmhWUm9tUDBNdQ==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"a2MrclFCU2xGQ0haWWtDVWU4RFZGY2JJOWpKRkYrcDkwMStPVG1OMzgrQVZlQ3RPenVkdTRjTWsxdzAvbkt0aw==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"bG9SL2J0MTVIM3RIZUs4Y1pmbUtUVll1ZlNKdFJuS1JIc1V3TFRJb2hWN3hkVGVsSVpaNVl6TUlhb1ZLMWFRTg==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"cVZSc1BBMEJtOTNhMGVrWVlZVGdPbU5Pc1ZCWTRLWUlDOUtvbDErQTVKbk11VE5rREcwenI5bnE0WW1pUSt0Lw==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"UGhPbHpmUG1OS0k0bDZMT25IS1lWNncrOTg0Q29vVG1yUnZVWFhicTFyTTBkdnU0bzdVUG5WVzlSMnpYV3VPag==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"cTVuQUtPd2tOQ0luN3ozUWQxbGZ5d25jRDRnN3Q5WjFSdlNlcEN1Y1Q4K0hETmhXM21ZbFpTMGNUSDBSNDlDdQ==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"cVRZSU8yYmdlMnhQYWc5TEN1Mk1jV0hkM0kvT2FldXpKQUF0MHNGM0t4SGM1MG1zamwrVExCUkNQdUJsRUVlbQ==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"TVI3NFdNM3ludzJzTWd0bEhVemdJQ0xvUDFuUGpxcnlGejZlTFRESjd4L2tHRE0rbkpxbDJnUmlWek1wTlhuWQ==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"M3I0Qm53a0dTRW9kUkVIcnh4UWRaZHQrcDVMTUVTcEY1dTZYZFlrVFB6bkZjNlB5S29EYVNTQU5HMTBiOGwwbg==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""},{"firstName":"","lastName":"","email":"[email protected]","status":"Unregistered","productsArray":[{"schemeIdSf":"d0dqVXd5b25wVFArWTFkc3l0dUV5SmhiZGs1ZC9UQXRtRGdQS3VHRTJjdWxXZUdWaXJjeXlBcm1rbWNMSUNjKw==","productName":"Healthy Living"}],"firstLogin":"","resendInvite":true,"isEmailVerified":"","canDeRegister":true,"products":"Healthy Living","contactId":"Q0dVVkhUMmdNbXgzNWFaY3hockg0QnY2cFFSN2ZNczZVR0xYd0cyMGpGZDBrSFR1Q2tlY0tYMm02YTh0KzY1SA==","pageNumber":1,"employeeReferenceNumber":"","deregisterInfo":{"reason":"","slug":"","date":""},"deregisterdate":""}]}
2

There are 2 answers

0
Dmitri T On

Your response seems to be JSON therefore it's better to consider using JSON JMESPath Extractor, example configuration:

enter image description here

In order to write the values into a file you can add a JSR223 PostProcessor and use the following code:

1.upto(vars.get('ContactID_Encrypt_matchNr') as int, { index ->
    new File('ids.csv') << vars.get('ContactID_Encrypt_' + index) << System.getProperty('line.separator')
})
3
Future Step On

You can do this using JSON Extractor also check this link