You would match that text inside of attribute values for other tags.
You fail to consider that the closing > can appear in the values of other attributes for the IMG tag. There are quite a few which could have it.
The alt attribute may be quoted with "", '', or nothing at all. You only deal with one of these cases.
There is optional whitespace between ALT and = and = and the value. Not accounted for.
In my experience the odds of your being bitten are highest for the different delimiter, then for munging up text that appeared in quoted delimiters. The others are possible but unlikely.
If you know your data, then an RE is OK. I have certainly done that. But if you don't, then an RE hack will break sooner or later...
In reply to Re (tilly) 3: Regex For HTML Image Tags?
by tilly
in thread Regex For HTML Image Tags?
by hostile17
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |