求一个正则表达式,请高手来帮帮忙阿
匹配形如这样的:<start> ......<end>也就是 以“<start>”开头,以“<end>”结尾,中间任意个任意字符。
请帮帮我啊,因为平时问题问的太多,就这10分了,不要嫌弃阿。

解决方案 »

  1.   

    string S = @"<start>Zswang <b>路过</b><end><start>hello<end>";
    Text = Regex.Match(S, "<start>(?!<start>|<end>)(.*?)<end>").Result("$1");
      

  2.   

    regex r=new regex(@"^<start>.*<end>$")
      

  3.   

    谢谢两位阿,但有个问题,就是,如果有换行怎么办呢,似乎有换行就不能匹配了如<start> sadfsdfsdaf
    缩短飞速地方
    <end>
      

  4.   

    try:
    regex r=new regex(@"^<start>(.|\s)*<end>$")
      

  5.   

    唉 ,还是不行啊<start> sadfsdfsdaf
    缩短飞速地方
    <end>
    是从文本里读出来的,然后到richTextBox里的
      

  6.   

    匹配单个的用这个Match m = Regex.Match(yourStr, @"<start>[\s\S]*?<end>", RegexOptions.IgnoreCase);
    if (m.Success)
    {
        string resultStr = m.Value;
    }匹配多个的用这个MatchCollection mc = Regex.Matches(yourStr, @"<start>[\s\S]*?<end>", RegexOptions.IgnoreCase);
    foreach (Match m in mc)
    {
         richTextBox2.Text += m.Value + "\n";   //匹配结果
    }