Hey, I am trying to separate a string containing firstname and lastname into first and lastname. Now it comes that this string not has firstname and lastname there are some line having firstname middlename and than lastname. Now the question is how to decide which is the lastname. One idea was to cound the spaces and do a split after the 2n space or just create an array.
Does there exist a function counting the occurence of spaces in a string?
Hello,
what you could do it use the length function after a split and check if it’s 2 or more.
Your first and last name would look like this:
Last name is simple because you want to get only the last word.
First name is more complex. In summary we say. Split the name with “space”, if we find 2 elements it means it’s simple John Doe. If we find more than 2, it means that there is a composed first name (or big chances there is). In that case we pick the 2 first items.
Copy and paste this, and change the mapping of the “name” field
{{if(length(split(1.name; space)) = 2; first(split(1.name; space)); first(split(1.name; space)) + space + get(split(1.name; space); 2))}}
Benjamin
Yes, you cannot simply deduce the first and middle names just by the spaces.
For example take this name: “One Two Three LAST”, where LAST is the Last Name,
Someone’s first name can be
- One Two Three (no middle name)
- One Two
- One (Two Three is the middle name)
Similarly, their middle name can also be
- Two Three
- Three (One Two is the first name)
The best solution is to capture the first, middle, and last names separately.
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!
I agree with @samliew, there are chances that you have other cases. I wonder if AI could help in that case?
Benjamin
Ai was my first idee but than I thought about the tokens and went the way Benjamin described. As I do have 10 Post to plan the post date I created a structure
like - var for the day - Task.
On the second day I took the date from the first date and added one day.
You might have posted this answer in the wrong thread, since your original question above has nothing to do with dates or AI.
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!