JavaScript regex for alphanumeric string with length of 3-5 chars

前端 未结 3 1034
旧巷少年郎
旧巷少年郎 2020-12-15 17:14

I need regex for validating alphanumeric String with length of 3-5 chars. I tried following regex found from the web, but it didn\'t even catch alphanumerics correctly.

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-15 17:50

    add {3,5} to your expression which means length between 3 to 5

    /^([a-zA-Z0-9_-]){3,5}$/
    

提交回复
热议问题