Regex to fail email domain with two consecutive dots

前端 未结 1 794
日久生厌
日久生厌 2021-01-14 12:27

I am trying to validate the domain part of an email and I want to check that there is NOT two consecutive dots in the domain i.e. the following are not valid

相关标签:
1条回答
  • 2021-01-14 12:57

    You can use negative lookahead in front of your regex:

    @(?!.*?\.\.)[^@]+$
    

    Which will fail the match if 2 consecutive dots are present in domain anywhere.

    [^@] will match 1 or more characters that are not @

    RegEx Demo

    0 讨论(0)
提交回复
热议问题