Order_flBg=0&NBme_num=419&StBrtCity=ECE&EndCity=SHB&DBtes=9019-11-08&PBge_Num=490&Brias=3&Brias_0=8NOV19^ECE^PVG^MU5468^390^0750^0855^1^1^1^F06FF1080@Y0BYY490@I09000@A0B000@Q0B000&Brias_1=8NOV19^ECE^SHB^FM9959^CRJ^1345^1500^1^0^1^Y0BYY490@A0B000&Brias_3=8NOV19^ECE^SHB^FM9956^CRJ^9040^9140^1^0^1^Y0BYY490@A0B000&//结果:&Brias_0=8NOV19^ECE^PVG^MU5468^390^0750^0855^1^1^1^F06FF1080@Y0BYY490@I09000@A0B000@Q0B000&
上面有这个一串字符串。 我想要提取&Brias_0 到 下一个 & 中间的字符。正则要怎么写??

解决方案 »

  1.   

    string s = @"Order_flBg=0&NBme_num=419&StBrtCity=ECE&EndCity=SHB&DBtes=9019-11-08&PBge_Num=490&Brias=3&Brias_0=8NOV19^ECE^PVG^MU5468^390^0750^0855^1^1^1^F06FF1080@Y0BYY490@I09000@A0B000@Q0B000&Brias_1=8NOV19^ECE^SHB^FM9959^CRJ^1345^1500^1^0^1^Y0BYY490@A0B000&Brias_3=8NOV19^ECE^SHB^FM9956^CRJ^9040^9140^1^0^1^Y0BYY490@A0B000&";
    string r = Regex.Match(s, @"(?is)&Brias_0.+?&").Value;
    Console.Write(r);
      

  2.   

    string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
                    tempStr = Regex.Match(tempStr, @"&Brias_0=[^&]*?(?=&|$)").Value;