regex, image src may have many different paths and I want to replace with a specific path -
so have database wordpress multisite. i'm doing search , replace on table regex , need create src's of specific image name (image2.jpg) point single directory. here's example. may have:
src="http://domain.com/path/weird/different/image2.jpg and
src="http://domain2.com/path2/differentpath/helloworld/image2.jpg i need replace between src=" , /image.jpg specific domain/filepath.
i'm not great regex stuff, try, it's not strong suit. help appreciated.
search: src="[^"]*image2\.jpg
replace: src="http://mydomain.com/mypath/image2.jpg
the [^"]* eats characters not double quote.
in demo, see substitutions pane @ bottom.
in php (should work wordpress):
$replaced = preg_replace('/src="[^"]*image2\.jpg/', 'src="http://mydomain.com/mypath/image2.jpg', $str); regex replace
No comments:
Post a Comment