Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Split first and last names

by hippo (Bishop)
on Nov 09, 2022 at 23:43 UTC ( #11148081=note: print w/replies, xml ) Need Help??


in reply to Split first and last names

The short answer is that it's not a solvable problem. See Falsehoods Programmers Believe About Names for why that is.

If you insist on storing data labelled as first name and last name then the best plan is to ask the person for those data items as separate fields (ie. change your web form).


🦛

Replies are listed 'Best First'.
Re^2: Split first and last names
by afoken (Chancellor) on Nov 10, 2022 at 20:44 UTC
    Falsehoods Programmers Believe About Names

    It goes even further.

    I know Mies van der Rohe (architect) from a street name, from an address change that once was important to me. I googled his name a long time ago, and that's almost all I remembered.

    The name "Mies van der Rohe" follows a common pattern for people with a history from the Netherlands, "$firstname van (der|den) $lastname". So, I almost automatically splitted his name into "Mies" and "van der Rohe". Guess how suprised I was when I heared "Ludwig Mies van der Rohe" recently. OK, so LMvdR surely had two first names, that's quite common here. "Ludwig" and "Mies" must be the first names, and "van der Rohe" the last name. WRONG! "Mies van der Rohe" was his last name.

    Just to annoy anyone handling names in computers, he was commonly refered to as "Mies" (which translates to english as lousy, crappy, bad). And to really annoy anyone handling names in computers, he was born as Maria Ludwig Michael Mies. A female first firstname, and no "van der Rohe" at all.

    Some more examples: Re^7: regex to return line with name but not if it has a number - and I guess the name of the second example in that post has drastically changed this year.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      > I guess the name of the second example in that post has drastically changed this year.

      You shouldn't confuse legal name and nobility titles.

      I'm pretty sure I read once, that he signed his marriage papers with Diana simply as "Charles Mountbatten-Windsor".

      Cheers Rolf
      (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
      Wikisyntax for the Monastery

        You shouldn't confuse legal name and nobility titles.

        I don't, but many, many, many people entering names and titles in database systems from previous jobs did. And not just nobility titles, but also acacdemic titles, job descriptions ("Accessor des Bergfachs" is my favorite one - I have no clue what that job is, except that it has something to do with mining). I was really happy not to find "cook" and "gardener" as titles ...

        I'm pretty sure I read once, that he signed his marriage papers with Diana simply as "Charles Mountbatten-Windsor".

        Sounds plausible. The fully "decorated" name with all titles and middle names would probably fill half a page and take half an hour to write down.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^2: Split first and last names
by Bod (Priest) on Nov 12, 2022 at 23:26 UTC
    If you insist on storing data labelled as first name and last name then the best plan is to ask the person for those data items as separate fields (ie. change your web form).

    As a marketer first and a programmer second and a DBA third, the form will not be changing! The reason is simple - more people fill in the form when we ask for the name as a single field than if we ask for it in two or three parts.

    We've tested pretty much every combination and found (for our audience) that the optimal form uses placeholders, not labels. It has three fields on the initial page which are labelled

    Your Name Your Phone (optional) Your Best Email
    If we need extra information (we rarely do) then we ask for it after we have captured the key details and stored them safely.

    As for the database storage...
    We store name information as follows:

    prefix firstname middle name(s) nickname lastname preferred firstname preferred fullname suffix

    The problem I see with storing the full name as they type it into a web form into the database is that we need to use both their full name (in an email to field perhaps or on the front of an envelope) but just their firstname in the salutaion. So we have to split it somewhere and, to my mind, it's best to do this early in the process - i.e. before storing it.

    We have discussed adding a separator component for terms like von but we have so few in our databse that we currently treat them as part of the lastname

      we need to use both their full name (in an email to field perhaps or on the front of an envelope) but just their firstname in the salutation

      Bod, though I know nothing of your (superb) business, it won't stop me from offering some free advice.

      If you're politely allowing them to enter anything their heart desires in the "Your Name" field -- and further assuming you're not being overwhelmed by a huge volume of registrations -- how about simply storing their preferred "Your Name" in your database ... and then later manually editing your new registrations, checking for goofs (and rude Turkish words) ... but also to manually enter a nice "salutation" field.

      Parsing human names is one niche where I suspect humans still outperform computers, as I discovered years ago when my company sent out a letter to "Dear Captain Cruises" after the computer program incorrectly derived a salutation from Captain Cook Cruises. :-)

        offering some free advice

        Free advice is always welcome. And given the giver, it will be taken very seriously...

        Your suggestion seems the most sensible. There are occasions when we get upwards of 100 new registrations in a day but those are very rare days. So the volume of data could easily be manually verified. The only issue being an automated email immediately after registration in many cases. Perhaps I need to anonymise that one.

        It's actually more complex still because we hold people's pets' names in our database and send some emails as Dear Eyespop and Fido. Plus, we add the dog's name into the body content. But it has to make sense when the name is present and when it is missing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148081]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2023-02-03 14:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (26 votes). Check out past polls.

    Notices?