双引号中间的任意字符串,怎么写正则如:sdfsfsfsf"dssss \r sdf\n   \\  /
/ s d在要工  \r"asdfawsd"fsfws"ef要找出"dssss \r sdf\n   \\  /
/ s d在要工  \r"和"fsfws"

解决方案 »

  1.   

    try...            Regex reg = new Regex(@"""[^""]*""");
                MatchCollection mc = reg.Matches(yourStr);
                foreach (Match m in mc)
                {
                    richTextBox2.Text += m.Value + "\n----------\n";
                }
      

  2.   

    string str = "sdfsfsfsf\"dssss \r sdf\n \\ // s d在要工 \r\"asdfawsd\"fsfws\"ef";            System.Text.RegularExpressions.Regex reg = new Regex(@"""([^""]*)""", System.Text.RegularExpressions.RegexOptions.IgnoreCase);            System.Text.RegularExpressions.Match match = reg.Match(str);            while (match.Success)
                {
                    string ret = match.Value; 
                    match = match.NextMatch();            }
      

  3.   

    字符串中间还有这样的转义那就加上\\""相或就行了如下:
     string str = "sdfsfsfsf\"dssss\\\" \r sdf\n \\ // s d在要工 \r\"asdfawsd\"fsfws\"ef";            System.Text.RegularExpressions.Regex reg = new Regex(@"""([^""|^\\""]*)""", System.Text.RegularExpressions.RegexOptions.IgnoreCase);            System.Text.RegularExpressions.Match match = reg.Match(str);            while (match.Success)
                {
                    string ret = match.Value;
                    str = str.Replace(ret, ret + "<br/>");
                    match = match.NextMatch();            }
      

  4.   

    试下,有不满足的给出实例            Regex reg = new Regex(@"""([^""\\]|\\""|\\\\)*""");
                MatchCollection mc = reg.Matches(yourStr);
                foreach (Match m in mc)
                {
                    richTextBox2.Text += m.Value + "\n----------\n";
                }现在开始的"前面是否为\没有做限制,一会回去再补充
      

  5.   


    现在出的问题是:
    ayersAll(),"中文.")
          sdfsf
        (),"|CFF20C
        .|r\n")
        call 出来的字符串是
    "中文."
    ")
        call ......
      

  6.   

    new Regex(@"""(\\""|""""|.)*""")串中可含 \"  或 "" 
      

  7.   

    这样写:
    new Regex(@"""(\""|""""|.)*""")
      

  8.   


    还是会出现
    "Mid\n",sdfsf,"Uncle !? What's wrong with you?"
    "Cid",sdfs,"Mid...no, not that…err…AARRGGHH!!!"
      

  9.   

    呵呵,再加个问号:
    new Regex(@"""(\""|""""|.)*?""")
      

  10.   


    good ! 能解释一下吗
    辛苦了
      

  11.   

    try...Regex reg = new Regex(@"""([^""\\]|\\""|\\)*""");
    MatchCollection mc = reg.Matches(yourStr);
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Value + "\n----------\n";
    }不过还不够严谨,再补充
      

  12.   

    本帖最后由 lxcnn 于 2010-04-22 22:59:25 编辑
      

  13.   

    本帖最后由 lxcnn 于 2010-04-22 23:06:54 编辑
      

  14.   

    sorry,我太勿忙了,对不起楼上的楼上的楼上了.只能说两位都辛苦了.