fork(2) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. List<String> strs = Arrays.asList(
  11. "abcDE 123", // Yes, this should match
  12. "!@#$%^&*", // Yes, this should match
  13. "aaàààäää", // Yes, this should match
  14. "ベビードラ", // No, this shouldn't match
  15. "😀😃😄😆");
  16. Pattern LatinPattern = Pattern.compile("\\p{ASCII}");
  17. for (String str : strs) {
  18. Matcher matcher = LatinPattern.matcher(str);
  19. if (!matcher.find()) {
  20. System.out.println(str + " => is NON ASCII");
  21. //return;
  22. } else {
  23. System.out.println(str + " => is ASCII");
  24. }
  25. }
  26. }
  27. }
Success #stdin #stdout 0.12s 36264KB
stdin
Standard input is empty
stdout
abcDE 123 => is ASCII
!@#$%^&* => is ASCII
aaàààäää => is ASCII
ベビードラ => is NON ASCII
😀😃😄😆 => is NON ASCII