从字符串中提取域名[关闭]

问题描述:

This is my code:

From: =?Shift_JIS?B?Y2VudGVyQHlhbWJnbGUuaW4ubmV0?= < center@yambgle.in.net >

From: =?x-sjis?B?+O6C6IKogvH47iAg?= < autovbxds@netltf.ladankhda.in.net >

I have the php code for the same, but I would like to have a preg_match code for the same.

Please help.

The following regex should do it

$data = 'From: =?x-sjis?B?+O6C6IKogvH47iAg?= < center@yambgle.in.net >';
if(preg_match('/@([^ ]*) /',$data,$result)){
    $domain = $result[1];
    echo $domain;
}

Result: yambgle.in.net