After trying (without success) to use regex to extract the NAME and LAST NAME of an user, I decided to do it thru javascript. It is a very very simple solution, so I decided to share it here so it may help others with this kind of need.
var name = PUT_YOUR_NAME_HERE
var name_array = name.split(" ");
console.log (name_array[0] + " " + name_array[name_array.length-1] )
What the code above do is to pick a full name and transform it in a Array, using the blank spaces between the words as separators. In the end, the code dysplays the FIRST and LAST element of the Array.
So a name as “Barack Hussein Obama” will create the Array:
var name_array = ["Barack", "Hussein", "Obama"]
First element: name_array[0] is Barack
Last element: name_array[name_array.length-1] is Obama
So, using Toolbox plugin, you can extract the result and post it back into Bubble. Very simple.
Similarly to andrew’s first solution, this extracts a list of the words in a string, you can then simply pull the first item to get the first name, and then “items from 2” to get the rest. It leaves the spaces behind and only extracts actual words.
In some Latin American countries it’s not unheard of to carry your mother and fathers last names. So maybe? But probably not in most cases
Or what if the first name was
Jared Jr.
You may miss this as well. Hmm. Idk. Just thinking of different scenarios.
Use my regex solution and then just use the last item in the extracted list. The last item is the last name. The first item is the first name. Item# 2 would be the middle name.