日期:2014-05-18  浏览次数:20396 次

提取信息中的图片链接,这个表达式是不是不完善?
System.Text.RegularExpressions.Regex   a   =   new   System.Text.RegularExpressions.Regex(@ "(s|S)(r|R)(c|C)   *=   *( '| " ")?(\w|\\|\/|\.)+( '| " "|   *|> )? ");
foreach   (Match   m   in   a.Matches(TextBox1.Text))
{
            Response.Write(m.Value+ " <br> ");
}

当src= "image/xxx.gif "时可以正确搜索去值
但是当src= "http://www.??.image/xxx.gif "时就只能打印出:   src= "http

请问大家怎么改进这表达式:
(s|S)(r|R)(c|C)   *=   *( '| ")?(\w|\\|\/|\.)+( '| "|   *|> )?

------解决方案--------------------
System.Text.RegularExpressions.Regex a = new System.Text.RegularExpressions.Regex(@ "src=([ ' " "]?)(? <url> [^ ' " "\s]*)\1? ", RegexOptions.IgnoreCase);
foreach (Match m in a.Matches(TextBox1.Text))
{
Response.Write(m.Groups[ "url "].Value + " <br> ");
}