Replacing Substrings and Splitting Strings
Sometimes it’s useful to replace parts of a string or to split a string into pieces. For this purpose, class String
provides methods replaceAll, replaceFirst and split. These methods are demonstrated in Fig. 14.23.
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.