The 's' replaces just one Room match at any given time even so the 's+' replaces The entire House sequence directly with the second 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://edwingarfu.boyblogguide.com/30611291/mantra-mushroom-gummies-no-further-a-mystery