Regular expression to match single dot but not two dots?

后端 未结 5 1573
广开言路
广开言路 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:43

    This seams more logical to me:

    /[^.]([\.])[^.]/
    

    And it's simple. The look-ahead & look-behinds are indeed useful because they don't capture values. But in this case the capture group is only around the middle dot.

提交回复
热议问题