31
Jul
03

RegExp to split Full Name into First, MI, Last

The question of splitting a full name into first, middle, and last came up today in the forums. This is a pretty common question with many possible solutions. I came up one solution which is a CFMX UDF that utilizes regular expressions to match the different possible combinations of individual names.

The following function, splitFullName, will accept a parameter fullName and return a structure containing keys firstName, mi, and lastName. Even if no matches are found, it will always return a structure with these three keys, but they might be blank.

I’ve tested the function with a few hundred names in the following forms:

  • First Last
  • First MI Last
  • Last, First
  • Last, First MI

The code also includes a function safeMid which is basically a wrapper for mid() but allows passing zero for the position or length without generating an error.


5 Responses to “RegExp to split Full Name into First, MI, Last”


  1. 1 discount Rulid Nov 5th, 2004 at 8:29 am

    Thank you for the coments on your website. Can you recomend a good location for me to find cheap medicines? My mama is not well right now. Can you advice? Thank you.

    Pablo Villarino

  2. 2 zone diet product Nov 5th, 2004 at 4:29 pm

    Hi - I was looking for some information on weight loss. Do you know a good site to visit?

    Thanks for your help
    Martin Brown

  3. 3 Buspar Nov 21st, 2004 at 9:30 pm

    Hey, interesting site, perhaps youd like to check out mine: Buspar

  4. 4 ambien Nov 24th, 2004 at 10:22 am

    Hey, interesting site, perhaps youd like to check out mine: ambien

  5. 5 Caiek Feb 3rd, 2007 at 8:03 am

    So much spam (

Comments are currently closed.