I need to strip the leading "…/"s from the src attribute of an html image tag.
For example:
<img src="…/…/…/bar/foo.jpg" />
Should become
<img src=“bar/foo.jpg” />
This is what I came up with:
preg_replace('#(<img.*?src=")[\./]*(.*?".*?>)#i', '$1$2', $text);
But it simply doesn’t work. I’m pulling my hair out over this one. :-/
Any suggestions?