public class RegexDemo4 {public static void main(String[] args) {String s="程序员学习java,"+"电话:181512516758,18512508907" +"或者联系邮箱:boniu@itcast.cn,"+"座机电话:01036517895,010-98951256"+"邮箱:bozai@itcast.cn,"+"热线电话:400-618-9090,400-618-4000,4006184000,4006189090";String regex="(1[3-9]\\d{9})|(\\w+@[\\w&&[^_]]{2,6}(\\.[a-zA-Z]{2,3}){1,2})" +"|(0\\d{2,3}-?[1-9]\\d{4,9})"+"|(400-?[1-9]\\d{2}-?[1-9]\\d{3})";//获取正则表达式的对象Pattern p=Pattern.compile(regex);//获取文本匹配器的对象//利用m去读取s ,会按照p的规则去找小串Matcher m=p.matcher(s);//利用循环去获取数据while(m.find()){String str=m.group();System.out.println(str);}} }