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 way of trimming spaces (if string might have a number of contiguous spaces) https://martinbshwj.idblogz.com/31887827/5-tips-about-mantra-mushroom-chocolate-you-can-use-today