Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple way to parse a person's name into its component parts?
    primarykey
    data
    text
    <p>A lot of contact management programs do this - you type in a name (<em>e.g.</em>, "John W. Smith") and it automatically breaks it up internally into:</p> <p><strong>First name:</strong> John<br> <strong>Middle name:</strong> W.<br> <strong>Last name:</strong> Smith</p> <p>Likewise, it figures out things like "Mrs. Jane W. Smith" and "Dr. John Doe, Jr." correctly as well (assuming you allow for fields like "prefix" and "suffix" in names). </p> <p>I assume this is a fairly common things that people would want to do... so the question is... how would you do it? Is there a <em>simple</em> algorithm for this? Maybe a regular expression?</p> <p>I'm after a .NET solution, but I'm not picky.</p> <p><strong>Update:</strong> I appreciate that there is no simple solution for this that covers ALL edge cases and cultures... but let's say for the sake of argument that you need the name in pieces (filling out forms - as in, say, tax or other government forms - is one case where you are bound to enter the name into fixed fields, whether you like it or not), but you don't necessarily want to force the user to enter their name into discrete fields (less typing = easier for novice users). </p> <p>You'd want to have the program "guess" (as best it can) on what's first, middle, last, etc. If you can, look at how Microsoft Outlook does this for contacts - it lets you type in the name, but if you need to clarify, there's an extra little window you can open. I'd do the same thing - give the user the window in case they want to enter the name in discrete pieces - but allow for entering the name in one box and doing a "best guess" that covers <em>most</em> common names.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload