Regular Expression For At Least One Number

前端 未结 3 1647
野趣味
野趣味 2020-12-17 08:09

How would you create a regular expression for a value that should contain at least one number? The user can enter any special character, letter etc., but should contain at l

3条回答
  •  天命终不由人
    2020-12-17 09:08

    Use this Regex

    An easier solution would be to retain your existing regex, then create two new regexes to test for your "at least one alphabetic" and "at least one numeric".

    So, test for this :-

     /^([a-zA-Z0-9]+)$/
    

    Then this :-

     /\d{1}/
    

    Then this :-

     /[A-Z]{1}/i
    

提交回复
热议问题