The 's' replaces a single Place match at a time even so the 's+' replaces The full Room sequence simultaneously with the next parameter.Even so x.replaceAll("s+", ""); are going to be more efficient way of trimming spaces (if string might have various contiguous Areas) for the reason that of probably a lot less no of replacements owing the to fact