I have the following regular expression to replace an html img tag with [IMG];
echo preg_replace('/(^<img) (.*) (>$)/i', '[IMG]', $subject);
It works as expected to a certain extent, however some of the img tags I'm working end with '/>' and some end with '>'. I can't get the above to work with the latter.
Sample 1 (works):
<img src="image-1.gif" alt="image-1" width="175>" height="80" />
Sample 2 (doesn't work)
<img src="image-2.gif" width="77" height="51" alt="image-2">
Appreciate the help.