PHP正则表达式

PHP正则表达式

 

 

mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )  搜索subject中匹配pattern的部分, 以replacement进行替换。对$subject变量并没有实质的改变。

 

<?php
	$string = 'April 15, 2003';
	$pattern = '/(\w+) (\d+), (\d+)/i';
	$replacement = '${1}1,$3';
	echo preg_replace($pattern, $replacement, $string);
?>

  输出:April1,2003

 

posted @ 2017-03-06 15:39  当归远志  阅读(202)  评论(0编辑  收藏  举报