Regex pattern to match at least 1 number and 1 character in a string

后端 未结 9 2434
既然无缘
既然无缘 2020-11-22 13:22

I have a regex

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

this just allows only alphanumerics but also if I insert only number(s) or only

9条回答
  •  囚心锁ツ
    2020-11-22 13:58

    While the accepted answer is correct, I find this regex a lot easier to read:

    REGEX = "([A-Za-z]+[0-9]|[0-9]+[A-Za-z])[A-Za-z0-9]*"
    

提交回复
热议问题