Reputation: 4545
To validate value With Length More than 7 And Contains Alphabetic
And Number
C-Characters i user the below Regex :
"^([A-Za-z][0-9])(\\w{7,})*"
Language is JAVA and \
most be \\
In this Language
Upvotes: 1
Views: 7710
Reputation: 5236
If you need to allow all digit or all alphabet inputs as well
You just need ^[A-Za-z0-9]{7,}$
which would accept any character from A to Z or a to z or 0 to 9 (denoted by the character class) occurring 7 or more times.
If you need to allow only if at least one digit and one alphabet is there
Use ^(?=.*[A-Za-z].*)(?=.*[0-9].*)[A-Za-z0-9]{7,}$
, which has look-aheads for alphabet (?=.*[A-Za-z].*)
and digit (?=.*[0-9].*)
to confirm that at least a digit and an alphabet is there, followed by a character class to restrict the characters to alphabets and letters set with a minimum length of 7.
Upvotes: 4