Sring Manipulation: How to get first and last names
“John M Stephen”
output :
John
Stephen
Thank You,
Sring Manipulation: How to get first and last names
“John M Stephen”
output :
John
Stephen
Thank You,
You can use the String manipulations to get the first and last name,
- Assign -> Name = "John M Stephen"
- Assign -> FirstName = Name.toString.Split(" ").First.Trim
- Assign -> LastName = Name.toString.Split(" ").Last.Trim
Check the below workflow for better understanding,
Or
If you want to concat First Name and last Name with space, use the below expression,
- Assign -> Name = "John M Stephen"
- Assign -> Output = Name.toString.Split(" ").First.Trim+" "+Name.toString.Split(" ").Last.Trim
Hope it helps!!
fullName = "John M Stephen"
nameParts = fullName.Split(" "c)
firstName = nameParts(0)
lastName = nameParts(nameParts.Length - 1)
@sagarinavya6
Assign the full name to a variable, e.g., fullName.
fullName = “John M Stephen”
-Split the full name into an array using the space character as the delimiter.
nameArray = fullName.Split(" "c)
-Assign the first name and last name to separate variables.
firstName = nameArray(0).Trim
lastName = nameArray(1).Trim
Cheers
lastSpaceIndex = fullName.LastIndexOf(" "c)
firstName = fullName.Substring(0, firstSpaceIndex)
lastName = fullName.Substring(lastSpaceIndex + 1)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.