比如有字符串:
s="播放1|http://www.xxx.com/vod..$$$播放2|http://www.fadfa.com/fdf$$$播放3|http://www.fsaf.com/我现在要根据“播放n" 来找到 跟在它后面的地址: 也就是“播放n|”  至  “$$$“的这中间一段地址,如何写?谢谢了!!

解决方案 »

  1.   

    string [] split = s.split("播放");
    foreach(string str in split)
    Console.WriteLine(str.substring(2,str.length));
      

  2.   

    string [] split1 = s.split("$$$");
    foreach  string tmp in split1
    {
    string[] split2=tmp.split('|')
    string url=split[1];//这个就是你要的地址 。 
    }
    //我也平时总是喜欢如你贴出的代码那样链接内容。  
      

  3.   

    string [] split1 = s.split("$$$");
    foreach  string tmp in split1
    {
    if(tmp=="")
        continue;
    string[] split2=tmp.split('|')
    string url=split2[1];//这个就是你要的地址 。 
    }呵呵补充一点   这个错误我犯了好多次了
      

  4.   

    using System.Text.RegularExpressions;string str = "播放1|http://www.xxx.com/vod..$$$播放2|http://www.fadfa.com/fdf$$$播放3|http://www.fsaf.com/$$$";
            Regex rx = new Regex(@"(?<=播放\d+\|)([^\$]+)(?=\$\$\$)");//匹配:取括号内的所有内容
            MatchCollection matches = rx.Matches(str);
            string s="";
            foreach (Match match in matches)
            {
                s += match.Value + "<br/>";
            }
    s 的结果为
    http://www.xxx.com/vod..
    http://www.fadfa.com/fdf
    http://www.fsaf.com/
      

  5.   

    string str = "播放1|http://www.xxx.com/vod..$$$播放2|http://www.fadfa.com/fdf$$$播放3|http://www.fsaf.com/$$$";        string strQuery = "播放2";
            Regex rx = new Regex(@"(?<="+strQuery+@"\|)([^\$]+)(?=\$\$\$)");
            Match match = rx.Match(str);
            
            Response.Write(match.Value);
    那么多答案让你参考,并一定是有你要的答案,但是你可以根据他人提供的做适当修改获得你想要的结果,别老等现成的,不是你想要的你一概拒绝,自己又什么都不做,干等着
      

  6.   

    那就这样:
    str=str.Substring(str.IndexOf("播放2|")+"播放2|".Length);
    int len1=str.Length;
    int len2=str.Substring(str.IndexOf("$$$"));
    string url=str.Substring(0,len2-len1);
      

  7.   

    int len2=str.Substring(str.IndexOf("$$$"))这句后边加.Length
      

  8.   

    是len1-len2
    不好意思不好意思^^!