The 's' replaces a single Room match at a time even so the 's+' replaces The entire House sequence directly with the 2nd parameter. Having said that x.replaceAll("\s+", ""); might be far more effective way of trimming Areas (if string might have a number of contiguous Areas) mainly because of https://mantra-euphoria-gummies85318.blog-eye.com/31440708/everything-about-s