System.Text.RegularExpressions.
Regex
regImg =
new
System.Text.RegularExpressions.
Regex
(
@"<img
\b
[^
<>
]
*?\b
src
[
\s
\t
\r
\n
]
*
=
[
\s
\t
\r
\n
]
*
[
""
'
]
?
[
\s
\t
\r
\n
]
*
(?<
imgUrl
>
[^
\s
\t
\r
\n""
'<>
]
*
)
[^
<>
]
*?
/
?
[
\s
\t
\r
\n
]
*
>"
, System.Text.RegularExpressions.
RegexOptions
.IgnoreCase);
// 取得匹配项列表
foreach
(
var
item
in
Model)
{
System.Text.RegularExpressions.
MatchCollection
matches = regImg.Matches(@item.Description);
var
sUrlList =
""
;
foreach
(System.Text.RegularExpressions.
Match
match
in
matches)
{
sUrlList = match.Groups[
"imgUrl"
].Value;
}
<
li
><
a
href
="#"><
img
src
="
@
item.ImageUrl
"
data-large
="
@
sUrlList
"
alt
="image01"
data-description
="
@
Html.Raw(item.Keywords)
"/></
a
></
li
>
}