The 's' replaces one particular Area match at any given time even so the 's+' replaces the whole 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://lukasldtho.wizzardsblog.com/31324313/about-mantra-euphoria-gummie