谁给我个用正则提取图片地址的例子
  最好是C#1.1或2.0的,,,,
非常感谢例如        
string string1="<img src=Http://pics.6642.com/Upload/05/gyyhdhsnyym/21.jpg><br>";我想得到Http://pics.6642.com/Upload/05/gyyhdhsnyym/21.jpg

解决方案 »

  1.   

    如果是取一个,这样string yourStr = .............;
    string result = "";
    Match m  = Regex.Match(yourStr,  @"<img[^>]*src=(['""]?)(?<img>[^'""\s>]*)\1[^>]*>", RegexOptions .IgnoreCase);
    if (m.Success)
    {
        result = m.Groups["img"].Value;
    }如果是取多个,这样string yourStr = ...............;
    MatchCollection mc = Regex.Matches(yourStr, @"<img[^>]*src=(['""]?)(?<img>[^'""\s>]*)\1[^>]*>", RegexOptions.IgnoreCase);
    foreach (Match m in mc)
    {
         richTextBox2.Text += m.Groups["img"].Value + "\n";
    }