这是一条有规律的手机短信,我要将其分割后插入数据表。BJ|001|Q31,500,2000#Q24,500,2000#Q04,600,2500#Q35,650,2500#Q48,700,3200#Q42,750,3500#Q66,800,4000#Q80,800,4000#Q59,800,4000#Q73,800,4000#W77,800,4000#W21,800,4000#W84,800,4000#W38,800,4000#W91,800,4000#W45,800,4000#W07,800,4000#W52,800,4000#W14,800,4000#W69,800,4000#B36,100,9000#B50,100,9000#B74,100,9000#B98,100,9000#B43,100,9000#B67,100,9000#B81,100,9000#B04,100,9000#但是肯定有人没有按照格式发,这样就无法插入到对应的数据表里。
请高人按照这格式写个IF语句

解决方案 »

  1.   


    我意思是想让高人帮我写这个规则,
    IF 某字段 符合这个规则
    {
      
    }
    else
    {
    }
      

  2.   

    A way to write regular expressions: copy a typical string, replace parts with corresponding meta elements.If it's too difficult to write a regular expression. Just make a utility function which accepts a string as a parameter and return a boolean value. That's much easier for a programmer.
      

  3.   

    string s = "BJ|001|Q31,500,2000#Q24,500,2000#Q04,600,2500#Q35,650,2500#Q48,700,3200#Q42,750,3500#Q66,800,4000#Q80,800,4000#Q59,800,4000#Q73,800,4000#W77,800,4000#W21,800,4000#W84,800,4000#W38,800,4000#W91,800,4000#W45,800,4000#W07,800,4000#W52,800,4000#W14,800,4000#W69,800,4000#B36,100,9000#B50,100,9000#B74,100,9000#B98,100,9000#B43,100,9000#B67,100,9000#B81,100,9000#B04,100,9000#";
    bool result = Regex.IsMatch(s, @"(?i)\w+\|\d+\|(?:[a-z]\d{2},\d+,\d+#)+");
    Response.Write(result);
      

  4.   

    string str1 = “你的字符”;
    string str2 = str1.split(new char[]{'#',','});
    str2 保存。。