求个正则
C# code
@"<img.*?src=[""'](.+?)[""'].*?>";
<img alt='11 ' src=0.jpg />
<img src='1.jpg' title='AA' alt='2 ' >
<img src="1ddd.jpg" title='IOO' alt='2233 ' >
src=没有单引号或双引号的情况,怎么匹配?
------解决方案--------------------
string str = @"<img alt='11 ' src=0.jpg />
<img src='1.jpg' title='AA' alt='2 ' >
<img src=""1ddd.jpg"" title='IOO' alt='2233 ' >";
var array = Regex.Matches(str, @"(?is)<img[\s\S]*?src=['""]?(?<src>[^'""\s]+)").Cast<Match>().Select(t => t.Groups["src"].Value).ToArray();
------解决方案--------------------string pattern=@"(?i)<img\b[^>]*?src=(['""]?)(?<src>[^'""\s]+?)\1[^>]*?>";
C# code
string str = @"<img alt='11 ' src=0.jpg />
<img src='1.jpg' title='AA' alt='2 ' >
<img src=""1ddd.jpg"" title='IOO' alt='2233 ' >";
string pattern=@"(?i)<img\b[^>]*?src=(['""]?)(?<src>[^'""\s]+?)\1[^>]*?>";
if(Regex.IsMatch(str,pattern))//判断是否匹配
{
//you do
}