1 下载一个oro的jar(apache.org有)
import org.apache.oro.text.perl.Perl5Util;
boolean rtn = false;
String str = "type:STRING(0,英语)"; 
Perl5Util p5u = new Perl5Util();
if(p5u.match("m/^(type)\\:(STRING)\\((0)\\,(英语)\\)$/",str)){
//if(p5u.match("m/^([a-zA-Z]*)\\:(STRING)\\((\\d)\\,(英语)\\)$/",str)){
rtn = true;
}

解决方案 »

  1.   

    补充:输入的字符串也可以是下面几种:
    String str1 ="TYPE: STRING";
    String str2 ="type: STRING(,英语)";
    String str ="type: STRING(0,)";
    怎样判断我数入的字符号串是合法的,并将每一项的值取出来??我写了一下,写的不对,请大家指教!!
    String str ="type: STRING(0,英语)"; Pattern ptn = Pattern.compile("(\\s*)(TYPE)(:)(\\s*)(\\w+)(\\s*)(\\()(\\d)(\\,)");//后面的汉字我不知道怎样匹配?请指教!!!如果是日文,而不是中文,请问能否实现      Matcher mth = ptn.matcher(str);
       if(mth.matches())
       {
         System.out.println("Yes");
       }
       else
       {
         System.out.println("No");
       }
      

  2.   

    原来那个问题已经给你答复了
    http://community.csdn.net/Expert/topic/3253/3253616.xml?temp=6.699771E-02
    就这个问题而言可以这样判断:String original =                     
            "element name\n" +            
            "   type: String(0,英语)\n" +   
            "   value: Child.subChild\n" +
            "   multi: \n" +              
            "element";                    
    String regex = "\\s*type:\\s+\\w+\\(.+,.+\\)";
    Pattern p = Pattern.compile(regex);           
    Matcher m = p.matcher(original);              
                                                  
    while (m.find()) {                            
        System.out.println(m.group());            
    }