The 's' replaces one particular Area match at any given time even so the 's+' replaces the whole Place sequence simultaneously with the 2nd parameter. Having said that x.replaceAll("\s+", ""); might be more economical strategy for trimming spaces (if string might have several contiguous Areas) mainly because of probably considerably https://mantra-mushroom-chocolate08631.blogdigy.com/not-known-factual-statements-about-mantra-mushroom-chocolate-46835363