I am trying to match an alphanumeric string with at least one digit.
The second condition is that it’s minimum length should be 3.
For example, the following strings should match
111
12345
ABCD1
123A
11AA11
And the following should not match
ABCD
AB
12
1A
I have got myself to a point where I can get the first condition right.
That is, having minimum one digit:
([a-zA-z0-9]*[0-9]+[a-zA-z0-9]*)
But I don’t have any idea to specify a minimum length. If I try using {3},
it will require minimum of 3 numbers.
Try using a positive lookahead to ascertain that there’s at least one digit, and use
{3,}to indicate that it should match at least 3 characters: