正则表达式后向引用,该如何解决
正则表达式后向引用PHP code$reg /(\d{2})\/(\d{2})\/(\d{4})/e$text 01/25/2009到02/02/2009$r
正则表达式后向引用
PHP code$reg = "/(\d{2})\/(\d{2})\/(\d{4})/e";$text = '01/25/2009到02/02/2009';$replace = "\${3},\${1}";echo preg_replace($reg, $replace, $text);
报错:syntax error, unexpected ','
如果将逗号去掉,输出“200901到200902 ”
把逗号换成别的符号也都会报错~
[解决办法]把e去掉