The sender has the usual form : Pascal GANAYE <p.ganaye@bigfot.com>
But it can also be : "Pascal GANAYE <p.ganaye@bigfot.com>"
Or : " Pascal GANAYE " <p.ganaye@bigfot.com >
Or : Pascal GANAYE [p.ganaye@bigfot.com]
Or : < p.ganaye@bigfot.com>
There is probably more syntax...
From this string I nead to extract both the Name (when available) and the email address.
I started to write
Code: Select all
if (preg_match("/ї^\s^"^']+@ї^\s^"^']+/",$email,$res)) {
$email = $resї0];
$name = preg_replace("/ї"'\s]*<.*>\s*ї"'\s]*/","",$email);
}
...I found a lot of regular expression for validation but nothing very appropriate for an analysis and name/email extraction from it.
Anybody can help me to find an elegant solution on this problem ?