fork(8) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.regex.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args)
  8. {
  9. String s="குமார்";
  10. List<String> characters=new ArrayList<String>();
  11. Pattern pat = Pattern.compile("\\p{L}\\p{M}*");
  12. Matcher matcher = pat.matcher(s);
  13. while (matcher.find()) {
  14. characters.add(matcher.group());
  15. }
  16.  
  17. // Test if we have the right characters and length
  18. System.out.println(characters);
  19. System.out.println("String length: " + characters.size());
  20.  
  21. }
  22. }
Success #stdin #stdout 0.08s 381184KB
stdin
Standard input is empty
stdout
[கு, மா, ர்]
String length: 3