The 's' replaces a single space match at any given time even so the 's+' replaces the whole Place sequence simultaneously with the 2nd parameter. On the other hand x.replaceAll("\s+", ""); is going to be a lot more effective technique for trimming spaces (if string might have a number of https://landendwncq.bloggosite.com/38000540/everything-about-s