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.). David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)