/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import java.util.regex.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { Pattern ptrn = Pattern.compile("(?U)(?>\\p{L}\\p{M}*+)+|[0-9]+|[^\\w\\s]"); List<String> res = new ArrayList<>(); Matcher matcher = ptrn.matcher(str); while (matcher.find()) { res.add(matcher.group()); } } }
Standard input is empty