# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"\bdetails:.*?(\/.*?\.png\b)"
test_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'\n")
subst = "$1/"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
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 Python, please visit: https://docs.python.org/3/library/re.html