我需要有关php regex的帮助,我想将电子邮件地址“[email protected]”拆分为“johndoe”和“@ example.com”
到目前为止,我有这个:preg_match('/<?([^<]+?)@/', '[email protected]', $matches);
我得到Array ( [0] => johndoe@ [1] => johndoe)
那么,我该如何更改正则表达式?
最佳答案
$parts = explode('@', "[email protected]");
$user = $parts[0];
// Stick the @ back onto the domain since it was chopped off.
$domain = "@" . $parts[1];
关于php - 正则表达式拆分电子邮件地址,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6850894/