Dynamically replace the &ldquo;src&rdquo; attributes of all <img> tags

mastlife

New Member
I have some HTML and want to replace the "src" attributes of all the img tags so that they point to copies of the identical images (although with different file names) on another host.So for instance, given these three tags\[code\]<IMG SRC="http://stackoverflow.com/questions/graphics/pumpkin.gif" ALT="pumpkin"><IMG BORDER="5" SRC="http://stackoverflow.com/questions/3808285/redball.gif" ALT="*"> <img alt="cool image" src="http://www.crunch.com/pic.jpg"/>\[/code\]I would like them replaced with\[code\]<IMG SRC="http://myhost.com/cache/img001.gif" ALT="pumpkin"><IMG BORDER="5" SRC="http://myhost.com/cache/img002.gif" ALT="*"> <img alt="cool image" src="http://myhost.com/cache/img003.jpg"/>\[/code\]I know there is some regexp magic to this, just not sure what it should look like (or if this is in fact the best way).
 
Back
Top