I would like to search a String
, and for a certain word, I would like to change only the first 3 letters
For example:
This is a java institute which insures that you are in that institute. ins!
I want to change the first 3 letter of institute (ins) to JSE, so the result will be:
This is a java JSEtitute which insures that you are in that JSEtitute. ins!
I have the following, but it is NOT doing the job perfectly:
public class ExistanceAndReplace {
public static void main(String[] args) {
String s = "This is a java institute of insurance and insu.";
if (s.contains("institute")) {
String s1 = s.replaceFirst("ins", "JSS");
System.out.println(s1);
}else{
System.out.println("not found!");
}
}
}
Any suggestions?