到目前为止Google表格中的公式:=REGEXREPLACE(REGEXREPLACE(D3923;"(http(s)?://)?(www\.)?";"");"/.*";"")也许可以简化...测试用例 https://www.domain.com/ => domain.com https://domain.com/ => domain.com http://www.domain.nl/ => domain.com http://domain.de/ => domain.com http://www.domain.co.uk/ => domain.co.uk http://domain.co.au/ => domain.co.au sub.domain.org/ => sub.domain.com sub.domain.org => sub.domain.com domain.com => domain.com http://www.domain.nl?par=1 => domain.com https://www.domain.nl/test/?par=1 => domain.com http2://sub2.startpagina.nl/test/?par=1 => domain.com 解决方案当前使用: =trim(REGEXEXTRACT(REGEXREPLACE(REGEXREPLACE(A2;"https?://";"");"^(w{3}\.)?";"")&"/";"([^/?]+)"))似乎工作正常更新时间:2016年7月7日(感谢所有帮助!)Hi I am trying to extract the rootdomain from URL string in Google Sheets. I know how to get the domain and I have the formula to remove www. but now I realize it does not strip subdomain prefixes like 'mysite'.site.com; where mysite is not stripped from the domain name.Question: How can I retrieve the domain.com rootdomain where the domain string contacts alphanumeric characters, then 1 dot, then alphanumeric characters (and nothing more)Formula so far in Google Sheets:=REGEXREPLACE(REGEXREPLACE(D3923;"(http(s)?://)?(www\.)?";"");"/.*";"")Maybe this can be simplified ...Test cases https://www.domain.com/ => domain.com https://domain.com/ => domain.com http://www.domain.nl/ => domain.com http://domain.de/ => domain.com http://www.domain.co.uk/ => domain.co.uk http://domain.co.au/ => domain.co.au sub.domain.org/ => sub.domain.com sub.domain.org => sub.domain.com domain.com => domain.com http://www.domain.nl?par=1 => domain.com https://www.domain.nl/test/?par=1 => domain.com http2://sub2.startpagina.nl/test/?par=1 => domain.com 解决方案 Currently using:=trim(REGEXEXTRACT(REGEXREPLACE(REGEXREPLACE(A2;"https?://";"");"^(w{3}\.)?";"")&"/";"([^/?]+)"))Seems to work fineUpdated:7-7-2016(thanks for all the help!) 这篇关于从Google表格中的URL字符串中提取根域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!