正则表达式

   string pattrn2 = "<sm>(?<sm>[\\s\\S]*?)</sm>";
                        MatchCollection results = Regex.Matches(IPstrLine, pattrn, RegexOptions.IgnoreCase);
                        MatchCollection results2 = Regex.Matches(IPstrLine, pattrn2, RegexOptions.IgnoreCase);
                        for (int j = 0; j < results.Count; j++)
                        {
                            string ip = results[j].Groups["ip"].Value.Trim();
                            string dk = results[j].Groups["port"].Value.Trim();
                            string sm = "";
                            try
                            {
                                sm = results2[j].Groups["sm"].Value;
                            }
                            catch { }

                            if (Xml_Data.CoreDS.Tables["ipdata"].Select("ip='" + ip + "' and qingkuang ='购买'").Length <= 0)
                            {
                                base.Invoke((MethodInvoker)delegate()
                                {
                                    Xml_Data.CoreDS.Tables["ipdata"].Rows.Add(new object[] { null, ip, dk, sm, "", "", "购买", 0, 0, true });
                                    worker.ReportProgress(0, "导入|IP正常处理保存 IP:" + ip + ":" + dk);
                                });
                            }
                        }

 

posted on 2014-09-23 23:04  HOT SUMMER  阅读(234)  评论(0编辑  收藏  举报

导航