The front part is letters [a-zA-Z]
(necessary), and the back part is digits (optional). total length >=1 && <= 80
.
Should match the following:
a
a1
ab12
aAc
aAd12
Should not match following:
1
1a
The front part is letters [a-zA-Z]
(necessary), and the back part is digits (optional). total length >=1 && <= 80
.
Should match the following:
a
a1
ab12
aAc
aAd12
Should not match following:
1
1a
In order to limit the whole length to 80:
^(?i)(?=.{1,80}$)[a-z]+\d*$
Explanation:
^ : beginning of line
(?i) : case insensitive
(?=.{1,80}$) : positive lookahead, make sure we have 1 upto 80 characters
[a-z]+ : 1 or more letters
\d* : 0 or more digits
$ : end of line
You could use anchors to assert the start ^
and the end $
of the line.
To match a lower or uppercase character one or more times you could use [a-zA-Z]+
followed by matching a digit 0 - 80 using a quantifier \d{0,80}
Edit:
If the total length should be 1 -80 you could use a positive lookahead (?=
to assert that what follows is [a-zA-Z0-9]{1,80}
until the end of the line $
Then match one or more times a lower or uppercase character [a-zA-Z]+
followed by zero or more times a digit [0-9]*
.