How to store all text after a space

I’m storing a text in the variable ${nombre completo} → Full name
Then I’m storing the first word as first name → ${nombre_primer_nombre}
And finally I want to trim the first word and store in another variable the rest of the text as Last Name → ${nombre_apellido}

My issue is that my code in ${nombre_apellido} is just storing the second word. How can I store the second and following words?

Example:

  • ${nombre_completo} = John Smith Iverson
  • ${nombre_primer_nombre} = John
  • ${nombre_apellido} = Smith Iverson

My code stores “Smith” instead of “Smith Iverson”

{
“Command”: “storeText”,
“Target”: “//*[@id="main"]/div/div/div[2]/ul/li[${!LOOP}]/div/div/div[2]/div/div/div/span/span/a/span/span”,
“Value”: “nombre_completo”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${nombre_completo}.split(" ")[0].trim();”,
“Value”: “nombre_primer_nombre”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${nombre_completo}.split(" ")[1].trim();”,
“Value”: “nombre_apellido”,
“Description”: “”
},

{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${nombre_completo}.split(’ ‘).slice(1).join(’ ');”,
“Value”: “nombre_apellido”,
“Description”: “”
}

@LEE thanks for your help!

I tested the code and it returns the full text after the first space. The issue now is that it deletes all spaces of the returned text.

Using the same example that I used in the opening message – it returns “SmithIverson” instead of “Smith Iverson”.

How can I make it keep the spaces after the first space?

Ty

return ${nombre_completo}.split(' ').slice(1).join(' ');

This last code marked within the code block worked perfectly. Don’t know why the other didn’t work as expected. Thank you very much!!