我想输出“xyz”而不是“www.xyz.com”。 主要是我问这个,因为我想知道如何提取模式之间的某些内容,除了模式本身。从给定地址提取域名Java正则表达式
public class Test {
public static void main(String[] args) {
Pattern p = Pattern.compile("www[.].+[.]com");
Matcher m = p.matcher("www.xyz.com");
if(m.find()){
System.out.println(m.group());
}
in.close();
}
}
有趣的问题了。如果你达到15代表,你想练习upvoting,我很高兴帮助;-) – GhostCat