fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. System.out.println(validateName("Dąb_rośnie$gdzieś#tu"));
  10. System.out.println(validateName("Some_string_here"));
  11. }
  12. private static boolean validateName(String name) {
  13. if (name.matches("(?U)\\p{L}+(?:[\\W_]\\p{L}+)*")) {
  14. return true;
  15. }
  16. return false;
  17. }
  18. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
true
true