In this article, we will see how to use format method of String to replace all word occurrences with case ignore in Java.
Lets look to our code.
String s1;
s1.replaceAll("[aA]ndromeda","vega");
Lets see it in an example.
In above example, we replaced all "andromeda" words in string object with "vega" with ignoring case and print it to terminal.