在mongodb中搜索并替换字符串为特殊字符


search and replace string with special characters in mongodb

我使用mongodb 2.4与cakephp,因为没有直接的方法来搜索和替换mongo数组中的字符串。我正在遍历所有记录并使用str_replace用特殊字符('/','+','-')等替换字符串。但是,如果字符串中出现多个特殊字符,则无法工作。请帮助我使用str_replace或其他方式来查找和替换mongo

一种方法是使用正则表达式,

<?php
    echo preg_replace('/('/|'+|-)+/i', ' ', $string);
?>