1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| function extraire_nom_prenom($string) {
//Recherche NOM Prénom
if (preg_match("#((?:\b[[:upper:]'\s-]+\b)+)\s+((?:\b[[:upper:]]?[\x6A\x6B\x6C\x6D\x6E\x6F\x61\x62\x63\x64\x65\x66\x67\x68\x69\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x2D\x82\xE9\xE0\xE7\xE8\xEF\xEE\xEB'\s-]+\b)+)#", $string, $m))
{
$resultat= array("nom"=>$m[1],"prenom"=>$m[2]);
$resultat_liste=array($resultat);
return $resultat_liste;
}
else {
//Recherche PRENOM NOM
if (preg_match("#((?:\b[[:upper:]'\s-]+\b)+)+((?:\b[[:upper:]'\s-]+\b)+)#", $string, $m))
{
$resultat= array("nom"=>$m[2],"prenom"=>$m[1]);
$resultat_liste=array($resultat);
return $resultat_liste;
} else
{
//Recherche Prénom NOM
if (preg_match("#((?:\b[[:upper:]]?[\x6A\x6B\x6C\x6D\x6E\x6F\x61\x62\x63\x64\x65\x66\x67\x68\x69\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x2D\x82\xE9\xE0\xE7\xE8\xEF\xEE\xEB'\s-]+\b)+)+((?:\b[[:upper:]]?[\x6A\x6B\x6C\x6D\x6E\x6F\x61\x62\x63\x64\x65\x66\x67\x68\x69\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x2D\x82\xE9\xE0\xE7\xE8\xEF\xEE\xEB'\s-]+\b)+)#", $string, $m))
{
$resultat= array("nom"=>$m[2],"prenom"=>$m[1]);
$resultat_liste=array($resultat);
return $resultat_liste;
}
}
}
} |
Partager