Home > Backend Development > PHP Tutorial > 请好手帮忙写段正则代码,有点难

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

WBOY
Release: 2016-06-13 12:52:49
Original
890 people have browsed it

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

<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 />
Copy after login


将上面的字符串中的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];//这里只是简单写了下函数的处理方式,实际上处理方式不是这么简单,只是作为事例; 
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template