Find Name with Regular Expressions
Hello
I'm going to expose you my problem about regular expressions.
I have a list of first names and last names at each line of a text:
$content="Bill Clinton
George W Bush
Jacques Chirac
John Fitzgerald Kennedy
Danny De Vito";
I would like to find the last name of John.
I made this function, but it works only if the last name is one word
if ( eregi("John+([a-zA-Z-])+\n", $content, $reg ) )
{
$identite = $reg[0];
print ">Identity: $identite<BR>";
}
I would like to have the text between John and the next \n
Regards, and thanks for your help,
Eric Vialle
|