If there's a regexp guru in the house who can give some direction i'd appreciated it.
i need to break down a single variable into 3. The variable contains the full name of a person and i need to break it down into the first name, middle name, and last name. The difficulty comes when you account for the various ways a name may be provided for (especially the middle name and sometimes nickname).
if there is a nickname its always surrounded by a quotes.
The var name is $name, there is only one var $name per script. Examples of all the different types of arrangements that the string $name my have:
John J. Smith
Albert Kemp 'Al' Johnson
Peter 'Pete' Friendly
Jane Fondu
Michael M. 'Mike' Yupa
Chris Ulysses Byod
Jesse George 'The Body' Ventura
the end result of the preg_match should be 3 new vars, f_name, m_name, l_name. End results of each above examples would look like this:
$f_name = 'John'; $m_name = 'J.'; $l_name = 'Smith';
$f_name = 'Albert'; $m_name = 'Kemp \'Al\''; $l_name = 'Johnson';
$f_name = 'Peter'; $m_name = '\'Pete\''; $l_name = 'Fondu';
$f_name = 'Jane'; $m_name = 'NULL'; $l_name = 'Smith';
$f_name = 'Michael'; $m_name = 'M. \'Mike\''; $l_name = 'Yupa';
$f_name = 'Chris'; $m_name = 'Ulysses'; $l_name = 'Byod';
$f_name = 'Jesse'; $m_name = 'George \'The Body\''; $l_name = 'Ventrua';
Obviously the difficulty here is the middle name ($m_name), there are many different variants (all listed). Once again, i only need the script to work on one name per load.
thanks guys, this forum is great,
c