Java Regex to Validate Full Name allow only Spaces and Letters -


i want regex validate letters , spaces. validate full name. ex: mr steve collins or steve collins tried regex. "[a-za-z]+\.?" didnt work. can assist me please p.s. use java.

public static boolean validateletters(string txt) {      string regx = "[a-za-z]+\\.?";     pattern pattern = pattern.compile(regx,pattern.case_insensitive);     matcher matcher = pattern.matcher(txt);     return matcher.find();  } 

what about:

  • peter müller
  • françois hollande
  • patrick o'brian
  • silvana koch-mehrin

validating names difficult issue, because valid names not consisting of letters a-z.

at least should use unicode property letters , add more special characters. first approach e.g.:

string regx = "^[\\p{l} .'-]+$"; 

\\p{l} unicode character property matches kind of letter language


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -