"String".replaceAll [1]

正規表現を指定して文字列を置き換えます。

String s1 = "Java and Python.";
System.out.println(s1.replaceAll("[pP]yt", "hoge"));