I have written below regular expression in java for checking the validity of a string, but unfortunately it doesn't work.
^[a-zA-Z][a-zA-Z0-9_]
Rule:
string can be alpha numeric and _ is the only allowed special chars
string can start with only alphabets a-z or A-Z
below java code returns false even though all conditions are met.
"a1b".matches("^[a-zA-Z][a-zA-Z0-9_]")