直接上方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 |
public
static ArrayList getImgUrl( string
html, string
regstr, string
keyname) { ArrayList resultStr = new
ArrayList(); Regex r = new
Regex(regstr, RegexOptions.IgnoreCase); MatchCollection mc = r.Matches(html); foreach
(Match m in
mc) { resultStr.Add(m.Groups[keyname].Value.ToLower()); } if
(resultStr.Count > 0) { return
resultStr; } else { //没有地址的时候返回空字符 resultStr.Add( "" ); return
resultStr; } } |
调用
var imgs=getImgUrl(pro.Description, @"<IMG[^>]+src=\s*(?:‘(?<src>[^‘]+)‘|""(?<src>[^""]+)""|(?<src>[^>\s]+))\s*[^>]*>", "src");
原文:http://www.cnblogs.com/xyangs/p/3552665.html