The 's' replaces 1 House match at a time however the 's+' replaces The complete Room sequence at once with the next parameter. Nonetheless x.replaceAll("\s+", ""); will probably be more economical means of trimming Areas (if string may have multiple contiguous spaces) because of doubtless much less no of replacements https://mantra-mushroom-chocolate64207.yomoblog.com/37716267/considerations-to-know-about-s