62,052
社区成员
发帖
与我相关
我的任务
分享
string page = "<input type=\"image\" height=\"325\" width=\"500\" src=\"FCKeditor/editor/filemanager/connectors/aspx/userfiles/image/B011627669461283B6A55B8611153813.jpg\" />";
string pattern = "<input type=\"image\" \\s+src=\"(?<src>[^\"]+?)\"[\\s\\S]*?>";
Regex _r = new Regex(pattern, RegexOptions.Compiled);
MatchCollection _m = _r.Matches(page);
string[] result = new string[_m.Count];
for (int i = 0; i < _m.Count; i++)
{
result[i] = _m[i].Groups["src"].Value;
Console.WriteLine(result[i]);
}
Console.ReadLine();
string str = "<input type=\"image\" height=\"325\" width=\"500\" src=\"FCKeditor/editor/filemanager/connectors/aspx/userfiles/image/B011627669461283B6A55B8611153813.jpg\" />";
System.Text.RegularExpressions.Regex reg=new System.Text.RegularExpressions.Regex(@"<input[^>].*?src=""(?<src>[^""].*)""[^>].*?>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.MatchCollection m = reg.Matches(str); //设定要查找的字符串
for (int i = 0; i < m.Count; i++)
{
Response.Write(m[i].Groups["src"].ToString()+"<br>");
}
Regex _r = new Regex(pattern, RegexOptions.IgnoreCase);
Regex _r = new Regex(pattern, RegexOptions.IgnoreCase);