Java regex replace multiple file paths in a large String

Posted by Joe Goble on Stack Overflow See other posts from Stack Overflow or by Joe Goble
Published on 2012-12-07T17:01:32Z Indexed on 2012/12/07 17:03 UTC
Read the original article Hit count: 261

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about regex