I am a new Java developer, I want to know how to check if the string contains only English letters or not. I search the but I got answer in PHP. I have not tried anything because I don't know.
Asked
Active
Viewed 512 times
2 Answers
0
You can use Java regex for that:
if((!str.equals(""))
&& (str != null)
&& (str.matches("^[a-zA-Z]*$"))) {
// Do something
}

Gaurav Jeswani
- 4,410
- 6
- 26
- 47
0
you can try somthing like
char c = 'h';
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
//english letter
}

Sideeg MoHammed
- 375
- 2
- 10