String Manipulations,,,!

Sring Manipulation: How to get first and last names

“John M Stephen”

output :

Thank You,

Hi @sagarinavya6

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,


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!!

1 Like


fullName = "John M Stephen"
nameParts = fullName.Split(" "c)
firstName = nameParts(0)
lastName = nameParts(nameParts.Length - 1)

1 Like

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


1 Like

Hi @sagarinavya6

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.