You will want to change your regex to search for not only a *
but for whitespace and additional *
's afterwards.
String str = "hi my name is * * * and * is * *";
String b = str.replaceAll("\\*(\\s+\\*)+", "*");
output:
hi my name is * and * is *