需求:
正则提取以以下结尾的domain:
.com.cn
.org.cn
.com
.net
.org
.cc
.biz
.uk
.info
.in
.eu
实现:
String regexStr = "(?<=//|)((\\w)+(\\.cn|\\.com.cn|\\.org.cn|\\.com|\\.net|\\.org|\\.cc|\\.biz|\\.uk|\\.info|\\.in|\\.eu))+";Pattern p = Pattern.compile(regexStr);Matcher m = p.matcher(url);String domainVal = StringUtils.EMPTY;if (m.find()) { domainVal = m.group();}