The 's' replaces 1 House match at a time however the 's+' replaces The complete House sequence without delay with the next parameter. On the other hand x.replaceAll("\s+", ""); is going to be a lot more effective technique for trimming spaces (if string might have a number of contiguous Areas) https://mantra-mushroom-chocolate55533.anchor-blog.com/11668222/helping-the-others-realize-the-advantages-of-mantra-mushroom-chocolate