const strings = [
'<img src="link">1234566 4553342 aaa',
'<div><img class="super-img" src="https://example.com"/></div>',
'src="1"',
'<img src=\'../img.png\'/>'
];
const expression = /img.+?src=(["'])(.+)\1/;
for (const string of strings) {
const src = (string.match(expression) || [])[2] ?? null;
console.log(string);
console.log(src);
}
/*
<img src="link">1234566 4553342 aaa
link
<div><img class="super-img" src="https://example.com"/></div>
https://example.com
src="1"
null
<img src='../img.png'/>
../img.png
*/