我正在將我發現的eregi_replace函數轉換爲preg_replace,但eregi字符串包含關於其中鍵盤上的每個字符。所以我試圖用英鎊作爲分隔符..目前它正在工作,但我想知道它是否可能會導致問題,因爲它是一個非標準的字符?可以在preg_replace中使用£作爲分隔符嗎?
這裏是eregi:
function makeLinks($text) {
$text = eregi_replace('(((f|ht){1}tp://)[[email protected]:%_\+.~#?&//=]+)',
'<a href="\\1">\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[[email protected]:%_\+.~#?&//=]+)',
'\\1<a href="http://\\2">\\2</a>', $text);
return $text;}
和預浸:
function makeLinks($text) {
$text = preg_replace('£(((f|ht){1}tp://)[-a-zA-^[email protected]:%_\+.~#?&//=]+)£i',
'<a href="\\1">\\1</a>', $text);
$text = preg_replace('£([[:space:]()[{}])(www.[[email protected]:%_\+.~#?&//=]+)£i',
'\\1<a href="http://\\2">\\2</a>', $text);
return $text;
}
這個神聖符號的褻瀆使者!女王將聽到這個消息。 – 2011-03-05 23:35:04