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' />