How to write regular expression to match only numbers, letters and dashes?

前端 未结 3 1140
太阳男子
太阳男子 2021-01-22 10:12

I need an expression that will only accept:

  • numbers
  • normal letters (no special characters)
  • -

Spaces are not allowed either.<

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-22 10:46

    [A-z0-9-]+
    

    But your question is confusing as it asks for letters and numbers and has an example containing a dash.

提交回复
热议问题