The 's' replaces 1 House match at a time nevertheless the 's+' replaces the whole Room sequence at the same time with the 2nd parameter. On the other hand x.replaceAll("\s+", ""); might be a lot more effective technique for trimming spaces (if string might have a number of contiguous Areas) https://mantra-mushroom-chocolate21975.csublogs.com/37947281/a-review-of-mantra-mushroom-gummies