20,359
社区成员
发帖
与我相关
我的任务
分享
$s ="PopPhoto.com and Think Tank Photo are offering one lucky reader the chance to win an amazingly versatile set of camera bags that should have you ready PopPhoto.com for just about any photo adventure you've got planned. All you've got to do is sign up for our weekly newsletter and you're automatically entered for a chance to win the prize package worth $1,146.00!Welcome to www.new1day.cn.";
$special[0] = array();
$special[1] = array();
//替换特殊的
$s = special_replace("/www\.[\w]+\.(com|cn|org)/i",$s);
$s = special_replace("/\.(com|cn|org)/i",$s);
$s = special_replace("/[0-9]\.[0-9]/",$s);
//分句
$temp =preg_split("/[\?\.\!]\s?/",trim($s));
array_pop(&$temp);
//还原每句
foreach($temp as $k => $v)
$temp[$k] = special_revert($v);
print_r($temp);
function special_replace($pattern, $str){
global $special;
preg_match_all($pattern, $str, $temp);
if(is_array($temp))
foreach($temp[0] as $k => $v){
$special[0][] = $v;
$special[1][] = $temp2 = "|".md5($v)."|";
$str = str_replace($v, $temp2, $str);
}
return $str;
}
function special_revert($str){
global $special;
return str_replace($special[1],$special[0],$str);
}
<?php
$s ="For the third year in a row, Drupal has been nominated for a Packt Publishing Open Source CMS award. Packt Publishing is announcing winners all week. Today they announced the 2008 best PHP open source CMS. ";
$temp =preg_split("/[\?\.\!]\s?/",trim($s));
array_pop(&$temp);
var_export($temp);
?>