php 用正则表达式获取链接并替换

1.提取链接


$pattern = ‘/next_flash_href=”<a href=\'(.*?)\’>(.*?)<\/a>”/i’;


$replacement = ‘next_flash_href=”$1″‘;


$PlayTemptext=preg_replace($pattern,$replacement,$PlayTemptext);


2.替换链接


$pattern = ‘/next_flash_href=”(.*?).html”/i’;


$replacement = ‘next_flash_href=”$1_play.html”‘;


$PlayTemptext=preg_replace($pattern,$replacement,$PlayTemptext);



 



SyntaxHighlighter.highlight();