The 's' replaces just one House match at any given time even so the 's+' replaces the whole space sequence at the same time with the next parameter.On the other hand x.replaceAll("s+", ""); will be much more productive means of trimming spaces (if string can have multiple contiguous Areas) because of potentially significantly less no of replacement