示例字符串:<img width=100 src="files.jpg"> This is a test page <img width=100 src="files2.jpg"> world, html <img width=100 src="ffword.jpg"> from here, wodd. <span></span><img width=100 src="files.jpg"> This is a test page <img width=100 src="files2.jpg"> hello world, html test <img width=100 src="ffword.jpg"> from here, wodd. <span></span> This is a test page <img width=100 src="files2.jpg"> hello world, html test <img width=100 src="ffword.jpg"> from here, wodd. <span></span>
取所有以"<img"开始和以"<span></span>"结束之间的字符串,但取到的字符串中只能含有一个"<img",另外取到的字符串中还应该含有 "hello"和"test"两个关键词。
例如前面的字符串中需要取到"<img width=100 src="files2.jpg"> hello world, html test <img width=100 src="ffword.jpg"> from here, wodd. <span></span>"
而其他的均不能匹配。
如以下字符串除了开始有<img,中间还有一个<img,所以不能匹配。
<img width=100 src="files.jpg"> This is a test page <img width=100 src="files2.jpg"> hello world, html test <img width=100 src="ffword.jpg"> from here, wodd. <span></span> 不匹配以下的也不能匹配(因为不含有hello和test)。<img width=100 src="files2.jpg"> world, html <img width=100 src="ffword.jpg"> from here, wodd. <span></span>请教这个正则表示式该如何取?
取所有以"<img"开始和以"<span></span>"结束之间的字符串,但取到的字符串中只能含有一个"<img",另外取到的字符串中还应该含有 "hello"和"test"两个关键词。
例如前面的字符串中需要取到"<img width=100 src="files2.jpg"> hello world, html test <img width=100 src="ffword.jpg"> from here, wodd. <span></span>"
而其他的均不能匹配。
如以下字符串除了开始有<img,中间还有一个<img,所以不能匹配。
<img width=100 src="files.jpg"> This is a test page <img width=100 src="files2.jpg"> hello world, html test <img width=100 src="ffword.jpg"> from here, wodd. <span></span> 不匹配以下的也不能匹配(因为不含有hello和test)。<img width=100 src="files2.jpg"> world, html <img width=100 src="ffword.jpg"> from here, wodd. <span></span>请教这个正则表示式该如何取?
解决方案 »
- .net中插入flv视频为什么只显示播放器 不播放视频文件呢
- 做一个定时打开一个网站,然后关闭这个网站的WEB,解决办法?
- ref int? returnvalue 这个的参数怎样给值
- 低级问题Session 怎么取值?
- 2008重写URL
- Gridview 动态绑定 想要隐藏某些列 的问题
- 急~~C#处理字符串的一个简单问题,在线等待回复!!
- 求解一个关于查询的问题,先谢了
- 请思归等大虾回答(关于设置IE打印页边距的问题,已经是第三次问了)
- 有人知道前台写css jiv bootstrap 后台asp怎么连吗
- url重写的问题
- 怎么向数据库中某一字段的某一行存入,像1,2,3,4,5 这样的形式存入
需求自相矛盾,你给的匹配结果中分明是有两个<img,怎么说是只有一个?难道是说中间必须包含且只能包含一个?
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
richTextBox2.Text += m.Value + "\n";
}