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' />
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…