Regex Letters, Numbers, Dashes, and Underscores

前端 未结 4 1742
盖世英雄少女心
盖世英雄少女心 2020-12-02 19:47

Im not sure how I can achieve this match expression. Currently I am using,

([A-Za-z0-9-]+)

...which matches letters and numbers. I would

4条回答
  •  庸人自扰
    2020-12-02 20:19

    Your expression should already match dashes, because the final - will not be interpreted as a range operator (since the range has no end). To add underscores as well, try:

    ([A-Za-z0-9_-]+)
    

提交回复
热议问题