The above statement results in replacing only "afile.html" part of the variable urlToReplace with the whole of newUrl.
So content1 now has "/en/US/products/http://myserver/LA/es/customer/afile.html" instead of expected "http://myserver/LA/es/customer/afile.html" .As you can see only the part after last "/" is getting matched and replaced.Even Pattern class usage does the same thing.
To test this, I wrote a quick class as follows. It compiles and runs fine giving you the new URL as the output.
Give it a go.
be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Joined: Jun 19, 2004
Guyz,it seems the replace method works as expected.It replaces the whole string as anyone would expect.There is absolutely no catch in that.
I found that there is some other piece of the code which was mingling with URLs and that was what created confusion.I had to spend 8-10 hours debugging this problem and to find out the root cause.
Sorry for wasting your time guyz.Thanks for lending a helping hand.