Split full name to first and last name

Hey, I want to split the name output into first and last name, how can I do that? which functions should I use

This should be strait forward.

you can split the string using IML at the “space” Between the names. and take 1st slot in the returned array for the first name, and 2nd slot for the last name.

this is more complicated if middle name or initial is included, or worse, if names have an inconsistent format.

let me know if you need more details than this i can provide some visual examples

Hey,
I would love to get visual examples, I don’t know what IML means as well

1 Like

IML are the functions used to insert/process data on modules

image
everything in this box each tab.


Example simple name splitter.

First Module sets an example name.
2nd module splits the name into an array of individual words.
then grabs the first in array as the first name
and the last in the array as last name,

This is the final result
image

:warning: Note, this is the simple version. you may have to account for “jr” after the last name, or middle initials. i do not off the top of my head know how stripe sends that data. Regular expressions or more complex IML should be able to handle more variance.
there are also cultural name formatting differences if you have to account for internationalization.

Hope this helps :smiley:

Go with this answer it has better coverage of name variation

Thank you @alex.newpath !

1 Like

This is really a great example of an explanation. You’ll probably have some edge cases like 3 names or more so you’ll need to explore regular expressions I think. Have a look at regex101.com and their library of common regular expressions.

2 Likes

Thank you so much Jugaadhi, btw I have 3 follow up questions
#1 Instead of creating a “set multiple variable” and adding the function there.

why don’t I add the same function in mailchimps first and last name field, will it work

#2 I saw a youtube video and they used this function, will that work as well
image

#3 what about splitting when a middle name is there, what can we do

oc

2

should also work, there are generally many different solutions to the same problem.
once you learn the basic patterns it mostly applies the across the platform on the majority of integrations.

3

See @alex.newpath links and extended solution in the post above yours it has links to resources on how to use regular expressions in :make:

1 Like