package com.regex;
import java.util.Arrays;
public class RegexTest {
public static void main(String[] args) {
test1();
test2();
}
private static void test2() {
String mail =
"qwer123456df@163.cn.com";
String regex =
"[a-zA-Z_0-9]+@[a-zA-Z0-9]+(\\.[a-zA-Z]{2,3}){1,}";
boolean b= mail.matches(regex);
System.
out.println(mail+
":"+b);
}
public static void test1() {
String ip_str=
"23.2.2.2 192.168.1.1 3.4.56.78";
ip_str = ip_str.replaceAll(
"(\\d+)",
"00$1");
System.
out.println(ip_str);
ip_str = ip_str.replaceAll(
"0*(\\d{3})",
"$1");
System.
out.println(ip_str);
String[] ips = ip_str.split(
" +");
Arrays.sort(ips);
for(String ip:ips){
System.
out.println(ip.replaceAll(
"0*(\\d+)",
"$1"));
}
}
}
转载请注明原文地址: https://ju.6miu.com/read-1294348.html