就是要实现字符串里面是[A-Z0-9]而且这个字符串不是OF

解决方案 »

  1.   

    static boolean testP(String s)
    {
    if(s.equals("OF"))
    return false;
    Pattern p=Pattern.compile("[A-Z0-9]*");
    Matcher m=p.matcher(s);
    return m.matches();
    }
      

  2.   

    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
      

  3.   

    "test".matches("\\w+") && 
    !"test".equals("OF");
      

  4.   

    大家没明白我的意思,我是需要用一个正则表达式做出来所有逻辑,不是靠分别的matches和equals。
    因为xml只设了一个reg的属性。
      

  5.   

    [A-MP-Z0-9][A-Z0-9]*|O([A-EG-Z0-9])[A-Z0-9]*)?