const regex = /\bdetails:.*?(\/.*?\.png\b)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\bdetails:.*?(\\\/.*?\\.png\\b)', 'gm')
const str = `'\\u001b[1m\\u001b[31m \\u001b[1m● \\u001b[1mregister page › register-automated › desktop › CONTROL\\u001b[39m\\u001b[22m\\n\\n Expected image to match or be a close match to snapshot but was 0.009980258828690502% different from snapshot (91 differing pixels).\\n \\u001b[1m\\u001b[31mSee diff for details:\\u001b[39m\\u001b[22m \\u001b[31m/src/pages/__image_snapshots__/__diff_output__/register-test-js-register-page-register-automated-desktop-control-1-diff.png\\u001b[39m\\n\\u001b[2m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 60 | \\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 61 | \\u001b[39m \\u001b[36mconst\\u001b[39m image \\u001b[33m=\\u001b[39m await page\\u001b[33m.\\u001b[39mscreenshot({ fullPage\\u001b[33m:\\u001b[39m isFullPage })\\u001b[33m;\\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m\\u001b[31m\\u001b[1m>\\u001b[2m\\u001b[39m\\u001b[90m 62 | \\u001b[39m expect(image)\\u001b[33m.\\u001b[39mtoMatchImageSnapshot({threshold\\u001b[33m:\\u001b[39m \\u001b[35m0.3\\u001b[39m})\\u001b[33m;\\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m | \\u001b[39m \\u001b[31m\\u001b[1m^\\u001b[2m\\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 63 | \\u001b[39m })\\u001b[33m;\\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 64 | \\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 65 | \\u001b[39m \\u001b[36mif\\u001b[39m(experimentName \\u001b[33m||\\u001b[39m experiementVariationName) {\\u001b[0m\\u001b[22m\\n\\u001b[2m\\u001b[22m\\n\\u001b[2m \\u001b[2mat Object.toMatchImageSnapshot (\\u001b[2msrc/command/getPageImageShot.js\\u001b[2m:62:25)\\u001b[2m\\u001b[22m\\n'
`;
const subst = `$1/`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions