import java.util.*; import java.lang.*; import java.io.*; import java.util.regex.*; class Ideone { { Pattern ptrn = Pattern.compile("(?U)(?>[^\\W\\d]\\p{M}*+)+|\\d+|[^\\w\\s]"); List<String> res = new ArrayList<>(); Matcher matcher = ptrn.matcher(str); while (matcher.find()) { res.add(matcher.group()); } } }
Standard input is empty