首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java正则婚配Url

2012-09-07 
java正则匹配Urlpublic static void getUrl(String file) throws IOException{final Stringregex ([a-z

java正则匹配Url
public static void getUrl(String file) throws IOException{final String regex = "([a-zA-Z]+://[www]?.[A-Z,a-z,0-9,\\p{Punct},\\+]+) " ;Pattern p =Pattern.compile( regex,Pattern.MULTILINE | Pattern.DOTALL); BufferedReader br;br = new BufferedReader(new FileReader(file));String line = null;while((line=br.readLine())!=null){Matcher m = p.matcher(line);while(m.find()){System.out.println(m.group());}}br.close();}

热点排行