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:

  1. it should alphanumeric only.
  2. it should contains @ least 1 alphabet , @ least 1 number.
  3. it should allow small letters.
  4. it's length should between 3 , 16 inclusive.
  5. the first character should alphabet.

ex:-

  1. abc - invalid (should have @ least 1 number also)
  2. ab9 - valid
  3. 9ab - invalid (should start alphabet)
  4. ab9 - invalid (no capital letters allowed)
  5. aa - invalid (length should @ least 3)
  6. 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

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -