php正则替换
$string = 'April 15, 2003';
$pattern = '/(\w+) (\d+), (\d+)/i';
$replacement = '${1}1,\3';
成都创新互联服务电话:18980820575,为您提供成都网站建设网页设计及定制高端网站建设服务,成都创新互联网页制作领域十年,包括广告设计等多个方面拥有多年的营销推广经验,选择成都创新互联,为网站锦上添花。
//$replacement = '${1}1,$3';
//$replacement = '${1}1,{3}';
echo preg_replace($pattern, $replacement, $string);
echo '
';
//-----------------------------
$string = 'The quick brown fox jumped over the lazy dog.';
$patterns = array();
$patterns[0] = '/quick/';
$patterns[1] = '/brown/';
$patterns[2] = '/fox/';
$replacements = array();
$replacements[2] = 'bear';
$replacements[1] = 'black';
$replacements[0] = 'slow';
echo preg_replace($patterns, $replacements, $string);
echo '
';
//---------------------------------
//$d = $db->select('select * from <{:task}> limit 2');
self::$_sql = preg_replace('/<{:\s*(.*?)\s*}>/', $this->_prefix . '\1', $sql);
$this->_res = MySQL_query(self::$_sql, $this->_db);
//---------------------------------
if (preg_match('/^p-(\d+)$/', $segment3, $m)) {
$page = intval($m[1]);
}
else if (preg_match('/^\d+$/', $segment3)) {
$task_type = intval($segment3);
if (preg_match('/^p-(\d+)$/', $setment4, $m2)) {
$page = intval($m2[1]);
}
}
preg_match_all("/{([^\}\{\n]*)}/e",$contents , $source);
echo preg_replace("/{([^\}\{\n]*)}/e", " ", $contents);
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
$str = "http://112.125.116.137:9012/llys//lldoctor";
$pattern = '/(http:\/\/[^\/]+\/)(.*)/i';
preg_match($pattern,$str,$result);
echo "aaaaaa" ; dump($result);
preg_match("/php/i", "PHP is the web scripting language of choice.",$result);
echo "bbbb" ; dump( $result);
preg_match('/http:\/\/[^\/]+\//i', $str ,$result);
echo "bbbb" ; dump( $result);
exit;
echo $this->serinfo ."|". U('Home/Public/psysSendMessages');
网页题目:php正则替换
URL分享:http://azwzsj.com/article/jhejjj.html