The 's' replaces 1 Room match at a time even so the 's+' replaces The complete Place sequence without delay with the next parameter.However x.replaceAll("s+", ""); will probably be extra successful way of trimming spaces (if string may have many contiguous spaces) due to the fact of doubtless considerably less no of replacements because of the to i