title: Want correct Regex to extract a text from responsetext from server and do JSON.parse on extracted text
body: <pre><code>await page.on(&quot;response&quot;, async (response) =&gt; {
          const request = await response.request();
          if (
            request.url().includes(&quot;https://www.jobs.abbott/us/en/search-results&quot;)
          ) {
            const text = await response.text();
            const root = await parse(text);
            root.querySelectorAll(&quot;script&quot;).map(async function (n) {
              if (n.rawText.includes(&quot;eagerLoadRefineSearch&quot;)) {
               const text = await n.rawText.match(
                   /&quot;eagerLoadRefineSearch&quot;:(\{.*\})\,/,
                 );
                 const refinedtext = await text[0].match(/\[{.*}\]/);
                //console.log(refinedtext);
                console.log(JSON.parse(refinedtext[0]));
                 }
            });
          }
        });
  </code></pre>
  <p>In the snippet I have posted a data which is in text format I want to extract <code>eagerLoadRefineSearch : { (and its content too)}</code> as a text with <code>regex</code> and perform <code>json.parse</code> on extracted text so that i get finally a json object of <code>&quot;eagerLoadRefineSearch&quot; : {}</code>.</p>
  <p>I am using <code>puppetter</code> for intercepting response. I just want a correct <code>regex</code> which can get me whole object text of <code>&quot;eagerLoadRefineSearch&quot; : {}</code> (with its content).</p>
  <p>I am sharing the response text from the server in this link <a href="https://codeshare.io/bvjzJA" rel="nofollow noreferrer">https://codeshare.io/bvjzJA</a> .</p>
  <p>I want to extract <code>&quot;eagerLoadRefineSearch&quot; : {}</code> from the data which is in text format in this <a href="https://codeshare.io/bvjzJA" rel="nofollow noreferrer">https://codeshare.io/bvjzJA</a></p>