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

后端 未结 9 2444
既然无缘
既然无缘 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 14:00

    If you need the digit to be at the end of any word, this worked for me:

    /\b([a-zA-Z]+[0-9]+)\b/g
    
    • \b word boundary
    • [a-zA-Z] any letter
    • [0-9] any number
    • "+" unlimited search (show all results)

提交回复
热议问题