I need some help in trying to figure out the java code to replace image URLs with two domains (mapping to the same site), to ensure that IE can download those files in parallel (achieve more than 2 files download trick for IE).
My Basic Design is have a ResponseWrapper filter which has the handle on response data.

Now once I have the html string, I want to replace every img url with 2 domains alternatively

I have the html with me which contains the following patttern as an example

<... href="/img/abc/def.jpg/>
<....src="/img/ghi/ijk.jpg/>
<....src="/img/ghi/xyz.jpg/>
<... href="/img/abc/lkm.jpg/>

I want to find this pattern and replace it with the following string

<... href="http://test1.com/img/abc/def.jpg/>
<....src="http://test2.com/img/ghi/ijk.jpg/>
<....src="http://test1.com/img/ghi/xyz.jpg/>
<... href="http://test2.com/img/abc/lkm.jpg/>
and so on.

Can somebody give me an idea of what should be the logic or algorithm to do this pattern replacement?