marquis820 wrote:What does this translate to? ([\s\r\n][>]*)
Actually, upon looking at it again, I think I left out one character:
$newString = preg_replace('/<img([\s\r\n][^>]*)[color=red]?[/color]>/i', '', $string);
The idea is to match anything starting with <img and optionally followed by a whitespace (\s) or carriage return (\r) or newline (\n) character, which is then followed by zero to any number of characters which are not a ">", finally terminated by a ">" character. The "?" after the closing ")" will then mean zero or one occurrence of that sub-pattern enclosed by the parentheses. So along with the case-insensitive flag after the pattern, it should match any of these:
<IMG>
<img />
<IMg src="blah.jpg">
<iMg
src=blah.jpg alt="this is a test" />