The 's' replaces 1 space match at any given time nevertheless the 's+' replaces The full Area sequence at once with the next parameter. Even so x.replaceAll("\s+", ""); is going to be a lot more effective technique for trimming spaces (if string might have a number of contiguous Areas) mainly https://alexiseulao.pointblog.net/new-step-by-step-map-for-s-73698505