How to check whether Cyrillic in the line?

0 like 0 dislike
3 views
How to check for Cyrillic?
For example, if the string is Cyrillic, it will display an error, and if all Latin, there will be no error?
How to do a similar test in java?
by | 3 views

2 Answers

0 like 0 dislike
Use the test strings with a regular expression.
In your case you need to look no forbidden characters, but rather to check that the string contains only allowed characters.
\rhttps://ru.stackoverflow.com/questions/569779/%D0%...
by
0 like 0 dislike
String s = "Test"; cyrillic boolean = s.chars() .mapToObj(UnicodeBlock::of) .anyMatch(b -> b.equals(UnicodeBlock.CYRILLIC));
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
33,652 users