Regular expression to match single dot but not two dots?

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

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

    That should do for the what comes before the @, I'll leave the rest for you. Note that you should optimise it more to avoid other strange character setups, but this seems sufficient in answering what interests you

    Don't forget the ^ and $ like I first did :(

    Also forgot to slash the . - silly me

提交回复
热议问题