\nbook Number:123\nbook price:tt\nForward Busy:tt\nForward Number:tt\N我想提取出123,就是: 和\N 之间的值谢谢了

解决方案 »

  1.   

    string s = "\nbook Number:123\nbook price:tt\nForward Busy:tt\nForward Number:tt\N
    ";
                Regex regex = new Regex(@"([\s\S]*?):([\s\S]*?)\n", RegexOptions.IgnoreCase | RegexOptions.Singleline);            foreach (Match m in regex.Matches(s.ToString()))
                {                MessageBox.Show(m.Result("$1"));
                    MessageBox.Show(m.Result("$2"));
       
                }
      

  2.   

    string s = "\\nbook Number:123\\nbook price:tt\\nForward Busy:tt\\nForward Number:tt\\N";
                Regex regex = new Regex(@"([\s\S]*?):([\s\S]*?)\\n", RegexOptions.IgnoreCase | RegexOptions.Singleline);            foreach (Match m in regex.Matches(s.ToString()))
                {                  Response.Write(m.Result("$2"));
       
                }
      

  3.   

    Text = Regex.Match(S, @"123(?!\\N).*?\\N").Value;
      

  4.   

    Text = Regex.Match(S, @"123(?!\\N).*?\\N").Value;
    ==========================
    123 是不一定的。(?<=:).+?(?=\N)
    ================
    怎么系统提示我无法识别的序列啊。我现在是这么写的,可是不行,无法识别的序列,哪里错了。
    string Number = Regex.Match(sReturn,@"(?<=book Number:).+?(?=\N)").Value;
      

  5.   

    @"(?<=book Number:).+?(?=\\[Nn])"
    //呵呵 正则中\很特殊有时候为了一个\要写4个\(\\\\)
      

  6.   

    Text = Regex.Match(S, @"\\nbook Number:[0-9]+\\((?!\\N).*?)\\N").Result("$1");
      

  7.   

    介是结果对马?
    nbook price:tt\nForward Busy:tt\nForward Number:tt
      

  8.   

    string str=@"\nbook Number:123\nbook price:tt\nForward Busy:tt\nForward Number:tt\N";
    str=Regex.Match(str,@"(?<=book Number:).+?(?=\\N)",RegexOptions.IgnoreCase).Value;
    这样忽略大小写 应该更适合你
      

  9.   

    不对
    我想
    nbook_price变量(我程序里面的)的时候返回tt

    nForward_Busy变量的时候返回还是后面的那个值tt(这个也可以是别的,如ssfsadf 等)不知道我说清楚了吗
      

  10.   

    string strTemp=book Number;
    @"(?<="+strTemp+":).+?(?=\\N)"
    //正则表达式 其实也是个字符串
      

  11.   

    谢谢了,搞定了,用cancerser(都是混饭吃,记得要结帖)的方法,再次感谢