0
我需要將4個ereg_replace表達式轉換爲preg_replace。 我一直在嘗試基於教程的各種組合,並沒有讓我的網站工作得太遠。將ereg_replace轉換爲preg_replace的奇觀
某種靈魂可以幫助我解決這些問題嗎?
$path = ereg_replace('\.[\.]+', '', $path); // remove any '..' (jumping up a directory)
$path = ereg_replace('/[/]+', '/', $path);
$back_url = ereg_replace('dir=[^\&]*', "dir=$back_directory", $this->current_url);
$dir_url = ereg_replace('dir=[^\&]*', "dir=$dirpath", $this->current_url);
感謝
你能告訴我們你已經嘗試什麼,是什麼問題? – kapa 2012-08-09 12:03:05
以下是[PCRE:與POSIX正則表達式差異](http://www.php.net/manual/en/reference.pcre.pattern.posix.php)手冊頁的鏈接。 – kapa 2012-08-09 12:04:50
我在表達式中添加了正斜槓, 例如: '$ path = ereg_replace(/'\.[\.]+/','',$ path); $ path = ereg_replace('// [/] +','//',$ path);' 我已經使用在線正則表達式檢查器驗證了這些,並指出了各種語法問題,所以他們通過檢查器,但實施時仍然失敗。 – lokust 2012-08-09 12:10:38