首页 新闻 搜索 专区 学院

正则取图片问题?急

0
悬赏园豆:5 [已解决问题] 解决于 2012-08-06 15:13

<img
                                    src="http://192,168.1.100:8080//UPLOAD/S/SHO112926.JPG" width="500px" height="500px" border="0" />

 

string productPic = GetRegValue("<img([\\w\\W]*?) width=\"500px\" height=\"500px\" border=\"0\" />", jg1);

 

我的正则是这样写的,但取不到图片地址,不知道正则错在那了,望高人指点

jason2013的主页 jason2013 | 小虾三级 | 园豆:1998
提问于:2012-08-06 11:58
< >
分享
最佳答案
1

有没有更多的 html 代码提供,

如果就这么点,直接 (?<=src=").*?(?=")

就可以了!

 

收获园豆:5
张坤 | 小虾三级 |园豆:1865 | 2012-08-06 12:18

好象不行啊

<a href="#" onclick="javascript:document.getElementById('DivPicture23568').style.visibility='visible';">
                           
                          
                                <img width="230px" height="230px" border="0"
                                src="http://192.168.1.100:8080//UPLOAD/S/FULL_SHO191153.JPG" /></a>

jason2013 | 园豆:1998 (小虾三级) | 2012-08-06 13:39

@wydycg: 你这正则是在 js ,还是啥语言用啊?

张坤 | 园豆:1865 (小虾三级) | 2012-08-06 13:40

@张坤: c#

jason2013 | 园豆:1998 (小虾三级) | 2012-08-06 13:51

@wydycg: 你把完整的 html 贴出来,谢谢!

张坤 | 园豆:1865 (小虾三级) | 2012-08-06 13:52

@张坤: 

<div>
                            <a href="#" onclick="javascript:document.getElementById('DivPicture23568').style.visibility='visible';">
                            
                           
                                <img width="230px" height="230px" border="0"
                                src="http://192.168.1.100:8080//UPLOAD/S/FULL_SHO191153.JPG" /></a><br />
                            <a href="#" onclick="javascript:document.getElementById('DivPicture23568').style.visibility='visible';"><img
                                    src="/images/cosmetics/PRODUCT/sc/ENLARGE.GIF" border="0"
                                    onMouseOver="javascript:this.src='/images/cosmetics/PRODUCT/sc/enlarge_o.gif'"
                                    onMouseOut="javascript:this.src='/images/cosmetics/PRODUCT/sc/enlarge.gif'" /></a><br /><br />

                            <DIV ID='DivPicture23568' align="center"
                            style="position: absolute;left: 30%;top: 20%;width: 500px; height: 520px; visibility:hidden; background-color:#FFFFFF; border: 1px dashed #777777; padding: 10px;"
                             >
                                <a href='#' onClick="javascript:document.getElementById('DivPicture23568').style.visibility = 'hidden';" ><img
                                    src="http://192.168.1.100:8080//UPLOAD/S/SHO191153.JPG" width="500px" height="500px" border="0" /></a>
                                <div align="right"><a href='#' onClick="javascript:document.getElementById('DivPicture23568').style.visibility = 'hidden';" >close</a></div>
                            </DIV>
                        </div>

jason2013 | 园豆:1998 (小虾三级) | 2012-08-06 14:18

@wydycg: 我不知道你怎么测试的,我这边可以提取出来,

(?<=src=").*?(?=") 可以取出  src="xxxx" 中的 xxx 内容,

我看了你的代码,我又改了一下

(?<=src=['"]).*?(?=['"]) 这样可以取出 src="xxxx" 和 src='xxxx' 中的 xxx 内容,

具体使用那种,看你需求,

 

这个问题回答就到此吧,感觉你问问题也不问的不清楚!

张坤 | 园豆:1865 (小虾三级) | 2012-08-06 14:23
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册