How can I split text that is saved in a variable

Hey. How can I split text that is saved in a variable? My robot gets text using activity “get text”. The text looks like this: a;b;c;d - four values separated by a conjunction.
I want each of the four words written in a different variable.
How can I do it?
I’m working on StudioX.

You wouldn’t write them into separate variables. You’d write them into an array. Create an Array(of string) variable. Then assign yourArrayVar = Split(textVar,“;”)

1 Like

@sullivanne

Use set variable value activity and pass the below synatx as per your requirement

if you want entire in a single value

create an array of type string

array=output.split(“:”)

or

firstvalue=outputvar.split(";"C)(0)

Secondvalue=outputvar.split(";"C)(1)

Thirdvalue=outputvar.split(";"C)(2)

fourthvalue=outputvar.split(";"C)(3)

cheers

1 Like

Thank You! It’s work! :star_struck:

1 Like

Hi @sullivanne

input= "a;b;c;d"
FirstValue= input.Split(";")(0)
SecondValue= input.Split(";")(1)
ThirdValue= input.Split(";")(2)
FourthValue= input.Split(";")(3)

Refer the below image for better understnading.

Hope it helps!!

1 Like

Assigning all these things to individual variables is extra work for no reason.

As I said, create an array of string and assign the Split to that. Then when you want to access the values you just use yourArrayVar(0) yourArrayVar(1) etc

Much simpler less overhead.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.