java范例

java

正则表达小示例

package com.together.img;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class ImageSpider {

 public static void main(String[] args) {
  try {
   BufferedReader br = new BufferedReader(new FileReader("c://date.jsp"));
   String line = "";
   while((line=br.readLine()) != null) {
    System.out.println("line:"+line);
    parse(line);
   }
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }

 private static void parse(String line) {
  Pattern p = Pattern.compile("[\\[file:///]+\\w+[|/]+\\w+\\.png+");
  Matcher m = p.matcher(line);
  while(m.find()) {
      System.out.println(m.group());
  }
 }


}

posted on 2007-10-26 13:36 王波 阅读(158) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: