From: Alex Young Date: 2007-06-25T18:12:25+09:00 Subject: Re: Regexp to split name? Michael Fellinger wrote: > On 6/25/07, Alex Young wrote: >> dblack@wobblini.net wrote: >> > Hi -- >> > >> > On Sun, 24 Jun 2007, darren kirby wrote: >> > >> >> quoth the Alex MacCaw: >> >>> Does anyone have an example of splitting a name into first and last >> >>> names? Or is just a case of doing string.split(' ')? >> >> >> >> I'd say a regexp is overkill here. >> >> >> >> irb(main):001:0> name = "Alex MacCaw" >> >> => "Alex MacCaw" >> >> irb(main):002:0> first, last = name.split >> >> => ["Alex", "MacCaw"] >> >> irb(main):003:0> first >> >> => "Alex" >> >> irb(main):004:0> last >> >> => "MacCaw" >> >> >> >> Note that you will have to do more work to accommodate middle names >> and >> >> titles, ie: Mr, Mrs, Dr etc... >> > >> > And also last names with spaces in them (von Trapp, Vaughn Williams, >> > etc.). >> > >> And titles with spaces in them (The Honourable, His Excellency, etc...). >> > > And international names (though the US seems to have a broad > assortment of them already) > Can open. Worms everywhere. :-) -- Alex