Heim > Artikel > Backend-Entwicklung > PHP的preg_replace函数的有关问题
PHP的preg_replace函数的问题
$string = "april 15, 2003";<br />$pattern = "/(/w+) (/d+), (/d+)/i";<br />$replacement = "/${1}1,/$3";<br />print preg_replace($pattern, $replacement, $string);<br />/* output<br /> ======<br />april1,2003<br />*/
<br />$patterns = array ("/(19|20)(/d{2})-(/d{1,2})-(/d{1,2})/",<br /> "/^/s*{(/w+)}/s*=/");<br />$replace = array ("//3///4///1//2", "$//1 =");<br />print preg_replace ($patterns, $replace, "{startdate} = 1999-5-27");<br />