Regular expression, How to allow combination of dot (period) and letters?

前端 未结 7 587
庸人自扰
庸人自扰 2020-12-31 08:30

I want to allow (.) and (a-zA-Z) letters and _ and - , I have some problems with the (.) ,

Any idea ?

Thanks in advance ,

Ish

7条回答
  •  萌比男神i
    2020-12-31 09:13

    This will do [a-zA-Z_.-]+

    Outside the character class, ([]), you need to escape the dot (\.)as it is a meta character.

    [a-z]+\.com  #matches `something.com`
    

提交回复
热议问题