2010-07-18 38 views
2

如何使用perl從字符串中提取電子郵件地址並將電子郵件地址放入變量中? 我的琴絃的樣子如何使用perl從字符串中提取電子郵件地址?

Ben Tailor <[email protected]> 
[email protected], [email protected], Ben Tailor <[email protected]> 

我tryed這

$string ="Ben Tailor <[email protected]>"; 
$string =~ /\b([^\s][email protected][^\s]+)\b/g ; 
print $string; 

和OUT把XAS:

Ben Tailor <[email protected]> 

有人有一個想法?

使用

Email::Valid->address($string); 

THX

+0

它會輸出相同的輸入字符串,因爲你所做的只是對它執行正則表達式匹配,然後再次輸出字符串。您沒有使用捕獲部分$ 1或替換s /// g; – dalton 2010-07-18 16:44:59

回答

相關問題