replace ereg_replace with preg_replace [duplicate]
问题 This question already has answers here : How can I convert ereg expressions to preg in PHP? (4 answers) Closed 7 months ago . Hi need to change the function ereg_replace("[\]", "", $theData) to preg_replace 回答1: To port ereg_replace to preg_replace you need to put the regex between a pair of delimiter Also your regx is [\] is invalid to be used for preg_replace as the \ is escaping the closing char class ] The correct port is preg_replace('/[\\\]/','',$theData) Also since the char class has