angularjs - Regular Expression for alphnumeric with first alphabet and at least one alphabet and one number -
i'm trying generate regular expression can satisfy following conditions:
- it should alphanumeric only.
- it should contains @ least 1 alphabet , @ least 1 number.
- it should allow small letters.
- it's length should between 3 , 16 inclusive.
- the first character should alphabet.
ex:-
- abc - invalid (should have @ least 1 number also)
- ab9 - valid
- 9ab - invalid (should start alphabet)
- ab9 - invalid (no capital letters allowed)
- aa - invalid (length should @ least 3)
- abcdefghijklmnop99 - invalid (length should @ least 16)
i tried following solution it's not working expected
/^(?=.*[a-z])[a-z0-9]{3,16}$/
i want use regex in ng-pattern check text input user.
i'd use:
/^[a-z](?=.*\d)[a-z\d]{2,15}$/
or, if want unicode compatible:
/^\p{ll}(?=.*\p{n})[\p{ll}\p{n}]{2,15}$/
Comments
Post a Comment