Regex to extract all image URLs from HTML string not correct
Do not use regex for this. Use the DOMParser API and its parseFromString() method.
let str = "<img src='https://www.example.com'>";
let DOMParsing = new DOMParser()
let parsed = DOMParsing.parseFromString(str, "text/html")
// Now you can use querySelector to target the wanted element
// or querySelectorAll and a loop for multiple elements
let imgURL = parsed.querySelector("img").src
console.log(imgURL)