The 's' replaces one particular House match at a time but the 's+' replaces the whole Room sequence directly with the second parameter.Even so x.replaceAll("s+", ""); might be far more productive technique for trimming spaces (if string may have many contiguous Areas) since of doubtless considerably less no of replacements owing the to incontrovert