现在要实现一个象记事本一样的查找功能比如说输入"abcd"能把不区分大小写的都查出来,也就是说有2的4次中排列,哪位大侠能告诉我怎么解决,最好有代码

解决方案 »

  1.   

    import org.apache.oro.text.regex.*;
    static void cycleMatch(String inputValue, String reg) {
    org.apache.oro.text.regex.PatternCompiler compile = new Perl5Compiler();
    try {
    Pattern p = compile.compile(reg,
    Perl5Compiler.CASE_INSENSITIVE_MASK);
    PatternMatcherInput input = new PatternMatcherInput(inputValue);
    org.apache.oro.text.regex.Perl5Matcher pm = new Perl5Matcher();
    MatchResult result = null;
    int i = 0;
    while (pm.contains(input, p)) {
    result = pm.getMatch();
    System.out.println("result =" + result.group(0));
    input.setBeginOffset(result.length());
    i++;
    }
    System.out.println("总共匹配" + i + "次");
    } catch (Exception ex) {
    System.err.println("循环方式的匹配发生错误" + ex.getMessage());
    }
    }
    以上是我引用的代码
      

  2.   

    需要 下载 apache 的 jakarta-oro.jar
      

  3.   

    jdk1.4以后,自带正则表达式的处理