Java regex replace multiple file paths in a large String
- by Joe Goble
So a Regex pro I am not, and I'm looking for a good way to do this. I have a large string which contains a variable number <img> tags. I need to change the path on all of these images to images/. The large string also contains other stuff not just these img's.
<img src='http://server.com/stuff1/img1.jpg' />
<img src='http://server.com/stuff2/img2.png' />
Replacing the server name with a ReplaceAll() I could do, it's the variable path in the middle I'm clueless on how to include. It doesn't necessarily need to be a regex, but looping through the entire string just seems wasteful.