HTML Regex / Find

Hi All,

I have done some googling, and reviewed the help section here, and i’ve come up blank.

I have a HTML response body that looks like this:

<div id="aws_footer">

                                <div id="aws_footer_button_container">

                                    <div class="button_container button-secci-container marginBottom15">

                                        <button onclick="openDocEnableButtonAndCapturePR('contract1_035f892c-ccb8-4576-b69f-9a2b032baf33_copy','true','contract', 'FAagreementMessage','0');return false;" class="button nullbutton" type="button" id="print">Print/view documents<span>Documents will open in a new tab</span></button>

                                    </div>

I am trying to extract only: contract1_035f892c-ccb8-4576-b69f-9a2b032baf33_copy

can anyone help please

I can do :

var html = cheerio(responseBody);

console.log(html)

However, the array is so big, when i try to search through in Postman, it crashes the console.

This is only based on your example html but I’m guessing that there’s more on that page so it might not work.

A very hacky and hardcoded way could be:

const $ = cheerio.load(pm.response.text())

let str = $('button').attr('onclick')

console.log(str.substr(33, 51))

It maybe hacky! but it 100% did the job! thank you so much for your help!

1 Like

Hi @danny-dainton, could you help me out with another regex issue i am having please?

I need to pull this out from here:

but i keep getting undefined…

const $ = cheerio.load(pm.response.text())

    let respondEntityId2 = $('Respond.CaseInfo.FormId').value;

    console.log(respondEntityId2);