ñlaksjdfñlaskdjf'; echo htmlspecialchars(preg_replace_callback("/\<(img)[^>]+src=[\"'](.*?)[\"'][^>]*\>/i","abc",$aaa1)); // the problem is that if img src are in capitals dont match :S, but if not it work perfectly, already i put /i at the end and nothing ?>