|
@@ -11,9 +11,9 @@ import java.util.regex.Pattern;
|
|
*/
|
|
*/
|
|
public class DomainUtils {
|
|
public class DomainUtils {
|
|
|
|
|
|
- private static final Pattern email = Pattern.compile("[a-z_A-Z0-9\\-.]+@[a-zA-Z\\-]+[.(a-zA-Z\\-)]+");
|
|
|
|
|
|
+ private static final Pattern email = Pattern.compile("[a-z_A-Z0-9\\-.]+@[a-zA-Z0-9\\-]+[.(a-zA-Z0-9\\-)]+");
|
|
|
|
|
|
- private static final Pattern domainPattern = Pattern.compile("((http://)|(https://))?(www\\.)?([0-9a-zA-Z\\-_]+(\\.[a-zA-Z]+){1,2})(/.+)?");
|
|
|
|
|
|
+ private static final Pattern domainPattern = Pattern.compile("((http://)|(https://))?(www\\.)?([0-9a-zA-Z\\-_]+(\\.[a-zA-Z0-9]+){1,2})(/.+)?");
|
|
|
|
|
|
|
|
|
|
public static List<String> getDomain(String text) {
|
|
public static List<String> getDomain(String text) {
|
|
@@ -38,9 +38,7 @@ public class DomainUtils {
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
- List<String> domain = getEmails("xjk.jk@qq.com 完全https://www.baidu.com.pro你好http://baidu.com.cn完全vbindex.html");
|
|
|
|
-
|
|
|
|
- System.out.println(domain);
|
|
|
|
-
|
|
|
|
|
|
+ System.out.println(getEmails("13729958080@163.com"));
|
|
|
|
+ System.out.println(getDomain("sub.163.com"));
|
|
}
|
|
}
|
|
}
|
|
}
|