import java.util.*; import java.lang.*; import java.io.*; import java.util.regex.*; class Ideone { { String text = "The urn was then carried for several rounds around the cremation site, for the last leg of the procession."; Pattern pattern = Pattern.compile("[\\p{L}0-9]+", Pattern.UNICODE_CHARACTER_CLASS); Matcher matcher = pattern.matcher(text); List<String> result = new ArrayList<>(); while (matcher.find()){ result.add(matcher.group(0)); } } }
Standard input is empty
[The, urn, was, then, carried, for, several, rounds, around, the, cremation, site, for, the, last, leg, of, the, procession]