1

How can I validate the Russian language? If I start and use russian, I'll receive: java.util.regex.PatternSyntaxException: Illegal character range near index 4 ^[а-ЯА-Яa-zA-Z ]+$

private Pattern onlyLetter = Pattern.compile("^[а-ЯА-Яa-zA-Z ]+$", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) ;
lor lor
  • 121
  • 7

1 Answers1

1

You can use \p{IsAlphabetic} is regular expressions in Java, which is Unicode-aware and can check if the characters are alphabetic.

See https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html, «Classes for Unicode scripts, blocks, categories and binary properties»

Peter Walser
  • 15,208
  • 4
  • 51
  • 78