我正在尝试使用preg_replace对使用file_get_contents从文件接收的内容
preg_replace("/'/'/data(.*?)'/'/enddata/i",$string,$contents);
$string = 'data new ';
//空格
$contents = '
//data
//enddata';
事情是preg_replace正在被执行,但没有更新:)
有什么想法吗?非常感谢使用/有助于在replace后返回值:)
.
不匹配换行符,除非您通过添加s
修饰符特别告诉它。
另外,尝试使用不同的分隔符。我个人的偏好是括号,因为它们从不需要转义,即使模式中有更多的括号:)
"(//data(.*?)//enddata)is"