Count a number of word

Hello,

I have long response and i want to count a number of word (“good”) in response. Can i do it? I tried to do something like “var count = pm.response.json().match(“good”)”, but it doesn’t work.

Hey @lissiamsn,

Welcome to the community! :trophy:

Not actually tried this out so it might not work but it’s worth a try :grin:

let str = pm.response.text();
console.log(str.split("good").length - 1);

It’s using pm.response.text() as that converts the response to text.

1 Like

Thank you! It’s work!

1 Like