You can try this:
String str = "SerbiaandEuropetheAmerica";
str = str.replaceAll("the", " the ");
str = str.replaceAll("and", " and ");
System.out.println("str = " + str);
It is the result:
str = Serbia and Europe the America
3
solved How to insert whitespaces before and after a word or character?