[Edited - Sorry Bart] I\'ve looked at other answers but struggling to match this. I want to wrap an image tag where the src is the second attribute (after title) with a specific
Try this :
$newString = preg_replace('`]*)src="\\.\\./\\.\\./images/([^"]+)"([^>])*>`','', $oldString);
Limitations are :
"
are replaced by '
in your img tags, you'll have to change the regexp
I agree with other commenters saying regexp are bad to parse HTML. But there's almost no parsing here and the format of things to replace seems to be under control (generated by tinymce).