How to get a specific int from the response

{
“Status”: 0,
“Message”: “Successfully received 47 items for Folder (Account_075), File (File_109) and IsBoolean (False) as expected”,
“Code”: 0

}

I need to get the int value between " received" and “items” words (in this case it is 47) and set it as a test variable for the following row in my test:

pm.response.to.have.jsonBody(“Message”, “Successfully received… as expected”)

Thanks!!!

Hi @Kyortush_13

Try this;

var body = responseBody;
var array = new RegExp("Successfully received (.*?) items for Folder").exec(body);
console.log(array[1]);

Output;

2 Likes

You can use the below Regex to get the integer.

let jsonResponse=pm.response.json();
let message=jsonResponse.Message;

let totalItems=message.replace(/\D/g,'');
console.log(totalItems);