alex_T
September 5, 2022, 10:17am
1
Hello everyone! I have a little problem that I’m sure has a really easy fix.
I have a list of strings variable that contains names. So listNames = [Traian Basescu, Nicusor Dan, Ioan Sirbu]
I want to get 2 other lists out of this list : one that contains the Surnames ( listSurname) and another that contains Family names (listLastName).
So listSurname = [Traian, Nicusor, Ioan] and listLastName = [Basescu, Dan, Sirbu]
I know that the names in the main list can pe split by the space between the names. But I don’t know the syntax for that…
What I tried was : Assign listSurname = listNames.ToString.Split(" "c).ToList , but that doesn’t work…
Thanks in advance guys!
Sanjit_Pal
(Sanjit Pal)
September 5, 2022, 10:28am
2
Hey you can use for each loop to iterate through the FullName list and create two more collection variable and add two Add To Collection activity in for each loop and pass the collection name and
Use item.Split(" “c)(0) for FirstNameCollection and item.Split(” "c)(1) for LastNameCollection
Thanks,
Sanjit
ppr
(Peter Preuss)
September 5, 2022, 10:34am
3
If we can rely on the space delimiting firstname / lastname
ListFirstName = listNames.Select(Function (x) x.Split(" "c).First()).toList
ListLastName = listNames.Select(Function (x) x.Split(" "c).Last()).toList
alex_T
September 5, 2022, 10:37am
4
That’s awesome! It works inside a for each loop! Thanks a bunch!
system
(system)
Closed
September 8, 2022, 10:37am
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.