The 's' replaces one particular Area match at any given time even so the 's+' replaces The entire House sequence simultaneously with the second parameter. On the other hand x.replaceAll("\s+", ""); is going to be a lot more efficient technique for trimming spaces (if string might have several contiguous Areas) https://cruzgnrvv.blogmazing.com/30713807/the-2-minute-rule-for-mantra-mushroom-chocolate