How to check whether a string contains at least one alphabet in java?
The regular expression you want is [a-zA-Z]
, but you need to use the find()
method.
This page will let you test regular expressions against input.
Regular Expression Test Page
and here you have a Java Regular Expressions tutorial.
Java Regular Expressions tutorial
You can use .*[a-zA-Z]+.*
with String.matches()
method.
boolean atleastOneAlpha = s.matches(".*[a-zA-Z]+.*");