日期:2014-05-17  浏览次数:20789 次

问一个有难度的问题,这个IF语句如何写呢?
这是一条有规律的手机短信,我要将其分割后插入数据表。

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语句




------解决方案--------------------
C# code
        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);