Split a string where there are spaces, put it into an array and then get the first and last items in the array (get a fistname and lastname variables from the string "John Smith") | Community
Skip to main content
PoppyJennings
New Participant
January 2, 2023
Question

Split a string where there are spaces, put it into an array and then get the first and last items in the array (get a fistname and lastname variables from the string "John Smith")

  • January 2, 2023
  • 1 reply
  • 575 views

I guess what I want to do is fairly simple but can't figure out how to do it and there is not much documentation with examples to help me out.

 

I want to take the string "John Smith" and split it at the space and create two variables

1) firstName: John

2) lastName: Smith

 

cannot fot the lifge of me figure out how to get this to work. Have tried splitting the string then using get to pull out the first and last items in the array but to no avail. Any help is much appreciated.

 

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

ChrisStephens
New Participant
January 13, 2023

If you are still trying to figure this out, here is how I would approach it.

1. Create a variable, {name array}, that has split({name};{space}), make sure you select the "space" keyword from the string tab

2. Create a variable for the first name, get({name array};1)

3. Create a variable for the last name, get(reverse({name});1)