Search code examples
javastringreplaceduplication

Remove duplicate string values


let s say i have a string

String link = "www.abc.com"

now i have another string

String actualLink = "www.abc.com//www.abc.com/content/detail.html"

now I need a method to check actualLink string and remove the dulpicate part with string link for example:

public String removeDuplicate(String link, String actualLink){
     ....
     return actualLink;    //so the actualLink will become to     "www.abc.com/content/detail.html"
}

any advise? thx


Solution

  • actualLink = actualLink.substring(actualLink.lastIndexOf(link));