2011-11-10 82 views
3

我正在寫一個解析郵件從pop3郵箱的應用程序。 我已經提取了郵件的附加文件,現在我想轉換郵件文本中的鏈接。如何將cid鏈接轉換爲http鏈接?

這意味着 我有這樣的:src="cid:[email protected]" ,我想是這樣的:src="http://xxx/image001.png"

你能不能幫我蒙山正則表達式嗎? preg_replace('/cid:/', 'http://xxx')現在如何刪除'@'後的序列?

謝謝

回答

5

嘗試用:

$input = 'src="cid:[email protected]"'; 
$output = preg_replace('/cid:(.*?)@[\w.]*/', 'http://xxx/$1', $input); 

// string(29) "src="http://xxx/image001.png"" 
+0

這是所有好的非常感謝你 –

相關問題