I\'m looking for the best approach for string find and replace in Java.
This is a sentence: \"My name is Milan, people know me as Milan Vasic\".
I want to repla
One possibility, reducing the longer form before expanding all:
string.replaceAll("Milan Vasic", "Milan").replaceAll("Milan", "Milan Vasic")
Another way, treating Vasic as optional:
string.replaceAll("Milan( Vasic)?", "Milan Vasic")
Others have described solutions based on lookahead or alternation.