Regex to extract top level domain from email address

后端 未结 4 707
一向
一向 2021-01-27 14:01

From email address like

xxx@site.co.uk
xxx@site.uk
xxx@site.me.uk

I want to write a regex which should return \'uk\' is all the cases.

<
4条回答
  •  渐次进展
    2021-01-27 14:21

    Simply .*\.(\w+) won't help?

    Can add more validations for "@" to the regular expression if needed.

提交回复
热议问题