package cn.zhengze;
import java.util.ArrayList;
import java.util.Arrays;
public class zhengze {
/**
* @param args
*/
public static void main(String[] args) {
//test1();
// test2();
test3();
}
public static void test1() {
String temp = 我我我.......我要学...学学学...编编编程程..;
temp=temp.replaceAll(\.+, );
temp=temp.replaceAll((.)\1+, $1);
System.out.println(temp);
}
private static void test2() {
/*
* 对ip地址排序
*
*/
String temp = 192.168.1.200 17.1.10.10.10 3.3.50.3 127.0.0.1;
temp=temp.replaceAll((\d+),00$1 );
temp =temp.replaceAll(0*(\d{3}), $1);
String[] ips =temp.split( +);
Arrays.sort(ips);
for(String ip:ips)
{
System.out.println(ip.replaceAll(0*(\d+), $1));
}
/* 结果:
* 3.3.50.3
17.1.10.10.10
127.0.0.1
192.168.1.200
*/
}
private static void test3() {
/*
* 校检邮箱地址
*/
String mail = abc12@sina.com;
String regex=\w+@[a-zA-Z0-9]+(\.[a-zA-Z]{2,3}){1,3};
boolean b =mail.matches(regex);
System.out.println(mail+:+b);
}
}
?