- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomainRegex.java
More file actions
Latest commit
24 lines (20 loc) · 571 Bytes
/
Copy pathDomainRegex.java
File metadata and controls
24 lines (20 loc) · 571 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
importjava.util.regex.Matcher;
importjava.util.regex.Pattern;
/**
* Author: dc0453
* Since: 2017/8/10 上午10:26
*/
publicclassDomainRegex {
/**
* 获取url域名部分,包括host:port这种形式的
*/
publicstaticfinalStringpattern = "(?<=[://])[^/]+(?=/?)";
publicstaticfinalPatternp = Pattern.compile(pattern);
publicstaticvoidmain(String[] args) {
Stringstr = "http://www.baidu.com";
Matcherm = p.matcher(str);
if (m.find()) {
System.out.println(m.group(0));
}
}
}