Use of replace,replaceAll,matches, . and ^ are discussed below.
String myString = "Its going to rain today";
System.out.println(myString);
String yourString = myString.replace("Its", "Is it");
System.out.println(yourString);
. is a wild card for any character. so all characters will be replaced by . in below example
String alphanumeric = "abcdefghiiiiiiiiiiik991";
System.out.println(alphanumeric.replaceAll(".", "Y"));
Carrot boundary matcher which we can type using shift + 6. It basically means start looking at the start of the String due to ^. and match the expression exaclty
System.out.println(alphanumeric.replaceAll("^abcdef", "ABC")); //This will replace abcdef in above String with ABC
Please note that ^ replaces only if starting of String is exact match to abcdef.So the second occurence of abcdef will not be replaced in below example
String newAlphanumeric = "abcdefghijiiabcdefiiiiiiiik991";
System.out.println(newAlphanumeric.replaceAll("^abcdef", "ABC"));
Carrot character and matches.The below will return false as for the matches class the entire String has to match not just the beginning of the String
System.out.println(alphanumeric.matches("^abcdef"));
The below will return true as we are matching the entire String
System.out.println(alphanumeric.matches("abcdefghiiiiiiiiiiik991"));