$string = 'A text <img src="https://google.com" alt="Google">';
preg_match('/src="([^"]+)"/', $string, $matches);
$matches[1]; // https://google.com
or with multiple images
$string = 'A text <img src="https://google.com"> and again <img src="https://laracsts.com">';
preg_match_all('/src="([^"]+)"/', $string, $matches);
$matches[1]; // ['https://google.com', 'https://laracsts.com']
@ajvanho What exactly is it you are trying to achieve? You can grab the URL between the " of the src attribute using src="(.*?)", that way the URL is available inside the $1 parameter.
Why is there no mention of img? Why do you include href, when img tags do not take the href attribute? It seems as though you are more interested in checking whether something is a valid image URL than in matching some URL that is specified inside an img tag. Note that the regex I provided does not check the validity of the URL; it just goes based on the fact that whatever appears in quotes in the src attribute is expected to be a valid URL. I did it this way because it is a practical assumption in many situations, and you weren't specific about what you really want. I will not update further if you can't ask a better question.