dblack / wobblini.net wrote:
> Hi --
> 
> On Mon, 25 Jun 2007, Dan Stevens (IAmAI) wrote:
> 
>> name = "Mr John Joe Peter Smith"
>> TITLES = ["Mr", "Mrs", "Ms", "Dr"]
>> a = name.split
>> last = a.pop
>> title = a.shift if TITLES.include? a.first
> 
> Have mercy on us Yanks and allow for a period :-)
> 
>> first = a.shift
>> middles = a
>>
>> title #=> "Mr"
>> first #=> "John"
>> middles #=> ["Joe", "Peter"]
>> last #=> Smith"
> 
> However:
> 
>   name = "Mr Andrew Lloyd Webber"
> 
>   # etc.
> 
>   title #=> "Mr"
>   first #=> "Andrew"
>   middles #=> ["Lloyd"]   (wrong)
>   last #=> Webber"        (wrong)
> 

name = "The Honourable Lord Andrew, the Baron Lloyd-Webber of 
Sydmonton", you mean?  It's hard to come up with a trickier example. 
Names are just *hard* - the only reliable way of handling them that I've 
found is to let users control it themselves...

-- 
Alex