The 's' replaces a single Room match at any given time though the 's+' replaces the whole space sequence at once with the 2nd parameter.On the other hand x.replaceAll("s+", ""); will be much more effective method of trimming spaces (if string might have multiple contiguous Areas) for the reason that of probably fewer no of replacements owing the to