多谢大家帮助!!!

解决方案 »

  1.   


    import java.util.regex.Matcher;
    import java.util.regex.Pattern;public class Regex {
    static final String regexStr = "6\\d*-\\d*9";
    public static void main(String args[])
    {
    Regex r = new Regex();
    r.doRegex(Regex.regexStr,"(010)623-0299");
    }

    public void doRegex(String regexString,String string)
    {
    Pattern pattern = Pattern.compile(regexString);
    Matcher matcher = pattern.matcher(string);
    if(matcher.find())
    {
    System.out.println(matcher.group());
    }
    else
    {
    System.out.println("NO match string");
    }
    }

    }一个简单的例子 更多函数功能,可以查看帮助文档
      

  2.   

    URL:http://www.regexlab.com/zh/regref.htm
    有正则表达式的概念和用法
      

  3.   


    String str="f8s97fw8e7";
    //用replace替换掉所有的数字
    str=str.replaceAll("[0-9]+","");
      

  4.   

    to 1楼:"6\\d*-\\d*9"Pattern pattern = Pattern.compile(regexString);Matcher matcher = pattern.matcher(string);能解释一下这三句吗?谢谢!