RegEx for Javascript to allow only alphanumeric

前端 未结 18 1434
轻奢々
轻奢々 2020-11-22 15:13

I need to find a reg ex that only allows alphanumeric. So far, everyone I try only works if the string is alphanumeric, meaning contains both a letter and a number. I just w

18条回答
  •  一生所求
    2020-11-22 15:24

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

    the above regex allows spaces in side a string and restrict special characters.It Only allows a-z, A-Z, 0-9, Space, Underscore and dash.

提交回复
热议问题