>  기사  >  백엔드 개발  >  请好手帮忙写段正则代码,有点难

请好手帮忙写段正则代码,有点难

WBOY
WBOY원래의
2016-06-13 12:52:49853검색

请高手帮忙写段正则代码,有点难

<br />
<br />
	<a href="http://ygtc.tmall.com//search.htm?userId=&shopId=57299517&view_type=&order_type=&spm=0&search=y&keyword=%BA%A3%BB%EA%C9%C0&price1=&price2=" target="_blank"><img  src="http://a.tbcdn.cn/kissy/1.0.0/build/imglazyload/spaceball.gif" src2="http://img01.taobaocdn.com/imgextra/i1/91615835/T2SFNZXdldXXXXXXXX_!!91615835.jpg_q75.jpg" data-ks-lazyload="http://img01.taobaocdn.com/imgextra/i1/91615835/T2SFNZXdldXXXXXXXX_!!91615835.jpg" alt=" 请好手帮忙写段正则代码,有点难 " ></a><br />
   <br />
</div><br />
<div style="width:1920px;padding:0;float:left;"><br />
	<br />
	<a href="http://ygtc.tmall.com/search.htm?orderType=_hotsell&viewType=grid&baobei_type=&keyword=%BA%A3%BB%EA%C9%C0&price1=&price2=" target="_blank"><img  src="http://a.tbcdn.cn/kissy/1.0.0/build/imglazyload/spaceball.gif" src2="http://img01.taobaocdn.com/imgextra/i1/91615835/T22K9BXohbXXXXXXXX_!!91615835.jpg_q75.jpg" data-ks-lazyload="http://img01.taobaocdn.com/imgextra/i1/91615835/T22K9BXohbXXXXXXXX_!!91615835.jpg" alt=" 请好手帮忙写段正则代码,有点难 " ></a><br />
   <br />
</div><br />
<div style="width:1920px;padding:0;float:left;"><br />
	<br />
	<a href="http://ygtc.tmall.com/shop/view_shop.htm?spm=a1z10.3.0.324.DukoCY&search=y" target="_blank"><img  src="http://a.tbcdn.cn/kissy/1.0.0/build/imglazyload/spaceball.gif" src2="http://img04.taobaocdn.com/imgextra/i4/91615835/T2Cmm8XixaXXXXXXXX_!!91615835.jpg_q75.jpg" data-ks-lazyload="http://img04.taobaocdn.com/imgextra/i4/91615835/T2Cmm8XixaXXXXXXXX_!!91615835.jpg" alt=" 请好手帮忙写段正则代码,有点难 " ></a><br />
   <br />
</div><br />
<div style="width:1920px;padding:0;float:left;"><br />
	<br />
	<a href="http://ygtc.tmall.com/search.htm?spm=a1z10.1.w3.1.hqslaa&orderType=_hotsell&viewType=grid&baobei_type=&keyword=%C6%A4%D2%C2&price1=&price2=" target="_blank"><img  src="http://a.tbcdn.cn/kissy/1.0.0/build/imglazyload/spaceball.gif" src2="http://img03.taobaocdn.com/imgextra/i3/91615835/T2YOeBXXdcXXXXXXXX_!!91615835.jpg_q75.jpg" data-ks-lazyload="http://img03.taobaocdn.com/imgextra/i3/91615835/T2YOeBXXdcXXXXXXXX_!!91615835.jpg" alt=" 请好手帮忙写段正则代码,有点难 " ></a><br />
   <br />


将上面的字符串中的src=""和src2=""和data-ks-lazyload=""中的""之间的内容提取出来,注意只要""之间的内容不包含""


------解决方案--------------------
echo preg_replace_callback('/( 请好手帮忙写段正则代码,有点难 )/is','foo',$s);
function foo($src) {
    return $src[1].md5($src[2]).$src[3].md5($src[4]).$src[5].md5($src[6]).$src[7];//这里只是简单写了下函数的处理方式,实际上处理方式不是这么简单,只是作为事例; 
}
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.