Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to separate names

Participant ,
Sep 19, 2009 Sep 19, 2009

I have to search LDAP to get email address. However, all I have to work with is a name, such as Joe Smith. I can plug that in and it will find it.

However, sometimes nothing will be returned because the name in LDAP will be Joe X. Smith, and I only have Joe Smith to work with.

How can I break up the name Joe Smith into a first name of Joe and lastname of Smith ? I think I can then use the first name and lastname variables to search, thus bypassing any names with a middle initial. Also, it if is reversed and I have Joe X. Smith to work with, how can I still break up into first and last names without the middle initial. I just want a first and lastname to work with, so I can use that to search LDAP.

If this is not the proper way, what would be the best way to get email addresses from LDAP.

Thanks for any help.

682
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 22, 2009 Sep 22, 2009

I assume the names are from a query and you have no control over their current format.  The first thing to consider would be if there is another location where you can get the same name already broken into first and last.  If that is not possible then you would likely want to result to using Regular Expressions and string parsing to break apart the name. 

Think of the name as a list of characters.  You would want to be looking to identify the locations of the first and last space characters in the string of characters.  Make sure to Trim() the variable prior to doing this to avoid spaces before and after the Name.  You would then want to grab every character to the left of the first space and every character to the right of the last space and place them into new strig varaibles.

Alternately you can treat the name as a space delimited list (which would most likely be easier) and then simply grab the first and last values in the list.


One problem I can see with this however is if you were to find standard Salutations and Suffix's within the names such as Mr., Ms, or Dr., PHD, ect...

In this case the number of salutations and suffix's is limited.  So you could go so far as to create a list of them to check for and then alter how you pull the characters.  For example if Mr. is found at the beginning you would remove it and use the next value as the first name.

Hope that helps provide an idea.

-Joe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 22, 2009 Sep 22, 2009
LATEST

The previous post provides the standard ways to break up the string into 'names'.

I would have picked the space deliminted list as the first choice:

<cfoutput>#listFirst("Joe Smith"," ")# *** #listLast("Joe Smith"," ")#</cfoutput>

But once one starts working with names and thinking about the whole wide world.  Names do not always break up into nice "firstName LastName" packets.  For example, how to handle the name "Mary Sue Angoline Von Long Name".  Her first name is "Mary Sue", her middle name is "Angoline" and her last name is "Von Long Name".  It will take very sophisticated and large code to get a computer to figure that out from a string.

Just wanted to warn you the dangers of unstructed name data!.. When the human who owns the name did not record what was their first, middle and last names a computer can often fail to guess it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources