1、邮箱的匹配
String mail = "asdf@sina.com"
String reg = "\\w+@\\w+(\\.\\w+)+";
mail.matches(reg);
2、ip地址排序
String ip = "192.168.68.23 102.43.46.66 10.2.45.3 2.2.2.2 8.10.22.1"
ip.replaceAll("(\\d+)","00$1");
ip.replaceAll("0(\\d{3})","$1");
String arr[] = ip.split(" ");
arr.sort();
arr.replaceAll("0(\\d+)","$1")
3、网页爬虫--获取网页的邮箱地址
Url url = new URL("http://192.168.1.254");
URLConnection conn = url.openConnection();
BufferedReader buf = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line =null;
String reg = "\\w+@\\w+(\\.\\w+)+";
Pattern p = Pattern.compile(reg);
while((line=buf.readLine())!=null){
Matcher m = p.matcher(line);
while(m.find){
System.out.println(m.group);
}}