You would have to convert the quote into an HTML quote, " I believe.... There are two reasons for this.... For one, HTML will not allow placing quotes inside of quotes.. (for example, <img src="image.gif" alt="this is a "real" picture"> would not work..., the quotes inside quotes need to be "😉.
So converting these before tossing the query into eregi should get rid of the problems in eregi and html.
As for a regular expression to replace these, I'm not really sure how it can be done... 🙁
You would have to change the format of your img tag to something like this:

Then you would be able to have quotes in your alt, however they would still need to be converted to " before placed in an <img> alt tag.
Hope my rambling helped out some...