Regex that does not allow consecutive dots

后端 未结 3 1449
我在风中等你
我在风中等你 2020-11-29 13:18

I have a Regex to allow alphanumeric, underscore and dots but not consecutive dots:

^(?!.*?[.]{2})[a-zA-Z0-9_.]+$

I also need to now allow

3条回答
  •  鱼传尺愫
    2020-11-29 13:41

    You can try this:

    ^(?!.*\.\.)[A-Za-z0-9_.]+$
    

    This will not allow any consecutive dots in the string and will also allow dot as first and last character

    Tried here

提交回复
热议问题