import java.util.regex.*;
  public class Gxjun{
    public static void main(String args[])
    {
      Pattern  p;    //模式对象
      Matcher  m;    //匹配对象
      String regex = "(http://|www)\56?\\w+\56{1\\w+\56{1}\\p{Alpha}+}"; 
      p =Pattern.compile(regex);
      String s="新浪:www.sina.cn,央视:http://www.cctv.com";     
      m=p.matcher(s);
      while(m.find()){
        String str=m.group();
        System.out.println(str);
      }
      System.out.println("剔除字符串中的网站地址后得到的字符串:");
      String result = m.replaceAll("");
      System.out.println(result);
    }
  }

 

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2022-02-16
  • 2021-06-08
  • 2022-01-14
  • 2021-11-15
  • 2021-09-14
猜你喜欢
  • 2021-06-10
  • 2022-12-23
  • 2021-07-25
  • 2022-02-13
  • 2021-09-29
相关资源
相似解决方案