数据库中有一串这样的数据:
图片地址1|200601/20060109225825277.jpg$$$图片地址2|200601/20060109225831656.jpg$$$图片地址3|200601/20060109225835281.jpg$$$图片地址4|200601/20060109225840268.jpg$$$图片地址5|200601/20060109225955944.jpg$$$图片地址10|200601/20060109230002906.jpg$$$图片地址7|200601/20060109230002286.jpg我现在想把"200601/20060109225825277.jpg""200601/20060109225831656.jpg"等这些图片地址信息取出来请问我怎么来实现 ,请大家帮忙 谢谢!!

解决方案 »

  1.   

    string str="图片地址1|200601/20060109225825277.jpg$$$图片地址2|200601/20060109225831656.jpg$$$图片地址3|200601/20060109225835281.jpg$$$图片地址4|200601/20060109225840268.jpg$$$图片地址5|200601/20060109225955944.jpg$$$图片地址10|200601/20060109230002906.jpg$$$图片地址7|200601/20060109230002286.jpg";string[] a=System.Text.RegularExpressions.Regex.Split(str,"$$$");
    for(int i=0;i<a.Length;i++)
    {
    string[] b=a[i].Split('|');
    Response.Write(b[1]);
    }
      

  2.   

    string str="图片地址1|200601/20060109225825277.jpg$$$图片地址2|200601/20060109225831656.jpg$$$图片地址3|200601/20060109225835281.jpg$$$图片地址4|200601/20060109225840268.jpg$$$图片地址5|200601/20060109225955944.jpg$$$图片地址10|200601/20060109230002906.jpg$$$图片地址7|200601/20060109230002286.jpg";string[] a= str.Replace("$$$","$").Split('$');
    for(int i=0;i<a.Length;i++)
    {
        Response.Write(a[i].Split('|')[1]);
    }
      

  3.   

    同意....lookatliu(独孤常败) \
      

  4.   

    用正则实现你的问题吧
    String SubjectString = "图片地址1|200601/20060109225825277.jpg$$$图片地址2|200601/20060109225831656.jpg$ $$图片地址3|200601/20060109225835281.jpg$$$图片地址 4|200601/20060109225840268.jpg$$$图片地址5|200601/20060109225955944.jpg$$$图片地址10|200601/20060109230002906.jpg$$$图片地址7|200601/20060109230002286.jpg";
    try {
    Regex RegexObj = new Regex("\\|.*?jpg");
    Match MatchResults = RegexObj.Match(SubjectString);
    while (MatchResults.Success) {

    MatchResults = MatchResults.NextMatch();
                    // 这里每一个匹配结果去掉开头的"|",然后保存 } 
    } catch (ArgumentException ex) {
    // Syntax error in the regular expression
    }
      

  5.   

    正则这样写,匹配结果可直接提取出来,不用再作处理:
    Regex reg = new Regex(@"(?<=\|).*?jpg");