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. 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. 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. Buspar says:

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

  4. ambien says:

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

  5. Caiek says:

    So much spam (

Leave a Reply