fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String str = "This `99 is my small \"yy\" xx`example_and_more ";
  11. Pattern ptrn = Pattern.compile("(?U)(?>[^\\W\\d]\\p{M}*+)+|\\d+|[^\\w\\s]");
  12. List<String> res = new ArrayList<>();
  13. Matcher matcher = ptrn.matcher(str);
  14. while (matcher.find()) {
  15. res.add(matcher.group());
  16. }
  17. System.out.println(res);
  18. }
  19. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
[This, `, 99, is, my, small, ", yy, ", xx, `, example_and_more]