时间:2021-07-01 10:21:17 帮助过:18人阅读
$string = "april 15, 2003";
$pattern = "/(/w+) (/d+), (/d+)/i";
$replacement = "/${1}1,/$3";
print preg_replace($pattern, $replacement, $string);
/* output
======
april1,2003
*/
$patterns = array ("/(19|20)(/d{2})-(/d{1,2})-(/d{1,2})/",
"/^/s*{(/w+)}/s*=/");
$replace = array ("//3///4///1//2", "$//1 =");
print preg_replace ($patterns, $replace, "{startdate} = 1999-5-27");