The 's' replaces a person Place match at any given time even so the 's+' replaces The complete Place sequence at the same time with the second parameter. Nonetheless x.replaceAll("\s+", ""); will probably be a lot more productive strategy for trimming spaces (if string can have several contiguous Areas) because https://mantra-chocolate-bars20863.jts-blog.com/30571047/everything-about-s