I want to convert this javascript regex to php regex. I have test the code can run.
<img.*?src='(?!http[s]*:\/\/img.[a-zA-Z0-9]*.test\/)(.*?)'
<img alt='' src='http://img.dev.teeeest/images/UID' />
<img alt='' src='https://img.deaaav.test.com/images/UID/' />
<img alt='' src='http://api.com/images/UID' />
<img alt='' src='http://img.deaSassav.test/images/UID' />
<img alt='' src='https://img.dev.test/images/UID' />
It will choose first three of these. I want php regex will have the same result.
$body = "<img alt='' src='http://img.dev.teeeest/images/UID' />
<img alt='' src='https://img.deaaav.test.com/images/UID.ux/' />
<img alt='' src='http://api.com/images/UID' />
<img alt='' src='http://img.deaSassav.test/images/UID' />
<img alt='' src='https://img.dev.test/images/UID' />";
$body = stripslashes($body);
$img_array = array();
preg_match_all('/<img[^>]*?src=[\'|\"](http[s]*:\/\/img.[a-zA-Z0-9]*.test\/[^"|^\']*?)[\'|\"][^>]*?>/isU', $body, $img_array);
$img_array = array_unique($img_array[1]);
echo "<pre>";
print_r($img_array);
echo "</pre>";
i use the website test https://regex101.com/ i attempt use add an ^ before http[s]. like this
<img[^>]*?src=[\'|\"](^http[s]*:\/\/img.[a-zA-Z0-9]*.test\/)[^"|^\']*?[\'|\"][^>]*?>
i want to negative what have this
http[s]*:\/\/img.[a-zA-Z0-9]*.test\/