Home > Backend Development > PHP Tutorial > 正则表达式后向引用,该如何解决

正则表达式后向引用,该如何解决

WBOY
Release: 2016-06-13 10:07:50
Original
987 people have browsed it

正则表达式后向引用

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$reg = "/(\d{2})\/(\d{2})\/(\d{4})/e";$text = '01/25/2009到02/02/2009';$replace = "\${3},\${1}";echo preg_replace($reg, $replace, $text);
Copy after login


报错:syntax error, unexpected ','
如果将逗号去掉,输出“200901到200902 ”
把逗号换成别的符号也都会报错~

------解决方案--------------------
把e去掉
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template