10
rated 0 times
[
15]
[
5]
/ answers: 1 / hits: 17844
/ 15 Years ago, wed, august 19, 2009, 12:00:00
In JavaScript I have a string containing a DOM fragment. How would I find and replace the src attribute of an image?
I would like to replace the path of all images with a new path but keeping the image name. Not all the paths are the same and can come from various locations.
My regular expression skills are poor at best.
For example:
Change
<img src='path/to/image/name.jpg' />
into
<img src='newPath/name.jpg' />
More From » regex