Rhys18
(Rizky Albert Hartono)
1
Hi,
I have a task to extract last name, but how to extract last name if it contains more than 3 words?
If I use .First and .Last, this name will work :
John Doe
First : John
Last : Doe
But what if the name is John Doe Smith? I want the result to be like this :
First : John
Last : Doe Smith
Anyone can help with this? Without regex if possible too. Thanks 
vrdabberu
(Varunraj Dabberu)
2
Hi @Rhys18
Try this:
Assign Activity -> fullName = "John Doe Smith"
Assign Activity -> nameParts = fullName.Split(" "c)
Assign Activity -> firstName = nameParts(0)
Assign Activity -> lastName = String.Join(" ", nameParts.Skip(1))
Regards
lrtetala
(Lakshman Reddy)
3
Hi @Rhys18
fullName = "John Doe Smith"
firstName = fullName.Split(" "c)(0)
lastName = String.Join(" ", fullName.Split(" "c).Skip(1).ToArray())
Output:

Regards,
vrdabberu
(Varunraj Dabberu)
4
Hi @Rhys18
Check the below flow for better understanding:
fullName = "John Doe"
fullName = "John Doe Smith"
Regards
Anil_G
(Anil Gorthi)
5
@Rhys18
you can use this
first - str.Split(" ",2)(0)
second - str.Split(" ",2)(1)

cheers
Rhys18
(Rizky Albert Hartono)
6
This one works like a charm!
Thank for the help guys 
1 Like
system
(system)
Closed
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.