From: Robert Dober Date: 2006-08-24T14:25:30+09:00 Subject: Re: regexp or not ------=_Part_102151_7769636.1156397128577 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 8/23/06, James Edward Gray II wrote: > > On Aug 23, 2006, at 2:16 PM, David Vallner wrote: > > > Josselin wrote: > >> I am not yet a big friend of reegxp.. and I don't actually know if > >> I should use it or any other function > >> but I'd like to know the easiest path to do the following : > >> I get a string person =3D 'Clara Mint" which is a full name > >> and I would like to find the object "id" in a collection using > >> this full name : > >> people =3D [ ["id" =3D> "1", "first" =3D> "Jack", "last" =3D> "Johnson= "], > >> ["id" =3D> "2", "first" =3D> "Ben", "last" =3D> "Kenneth"], ["id" =3D> > >> "3", "first" =3D> "Ken", "last" =3D> "Olsen"], ["id" =3D> "4", "first" > >> =3D> "Howard", "last" =3D> "Wong"], ["id" =3D> "5", "first" =3D> "Clar= a", > >> "last" =3D> "Mint"], ["id" =3D> "7", "first" =3D> "Che", "last" =3D> > >> "Guevara"]] > >> any hint to start ? > >> Joss > > > > first, last =3D person.split(/\s+/) > > found_person =3D people.find { | person | > > person["first"] =3D=3D first and person["last"] =3D last > > } > > Be warned, parsing names correctly is a non-trivial task... > > James Edward Gray II (Hint, hint!) > > P.S. My wife's name is Dana Ann Leslie Gray, so don't forget to > handle that too. ;) > > P.P.S. I smell Ruby Quiz material... :D You bet you do there are Italian and Hungarien names, which are the other way round, Spanish names where you can assume that there are two surnames.... And I do not even know the rules (yet) on Alpha Centauri. Cheers Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_102151_7769636.1156397128577--