Regular expression to match single dot but not two dots?

后端 未结 5 1552
广开言路
广开言路 2021-01-05 09:12

Trying to create a regex pattern for email address check. That will allow a dot (.) but not if there are more than one next to each other.

Should match: test.test@te

5条回答
  •  一整个雨季
    2021-01-05 09:35

    To answer the question in the title, I'd update the RegExp by Junuxx and allow dots in the beginning and end of the string:

    '/^\.?([^\.]|([^\.]\.))*$/'
    

    which is optional . in the beginning followed by any number of non-. or [non-. followed by .].

提交回复
热议问题