Hi everyone.
I’m working in an automation which has a variable called ID.
That ID is written this way: prefix, “-”, IDNumber, “-”, VerificationNumber.
I want to split that text in order to get the prefix on one hand and the IDNumber + VerificationNumber on the other.
I’ve tried ID.Split(“-”)(1) and it didn’t work out.
Appreciate your help.
Regards,
vrdabberu
(Varunraj Dabberu)
2
Hi @Rodrigo_Martinez
Can you give an sample input and required Output.
Regards
Hi Varunraj.
The input can be:
1-1234567-8
2-9876543-1
24-6543210-9
The expected output is:
|Prefix| ID | Verification Number
|1 | 1234567 | 8 |
|2 | 9876543 | 2 |
|24 | 6543210 | 9 |
@Rodrigo_Martinez,
Use this in assign activity strArray would be string array datatype variable.
strArry=StrInput.Split("-")
From this array you can get values by index like I’d can be extracted by
Id=strArray(1)
Prefix
prefix=strArray(0)
Verification Number
varNo=strArray(2)
Thanks,
Ashok 
vrdabberu
(Varunraj Dabberu)
7
Hi @Rodrigo_Martinez
Check the below syntax then:
Assign Activity -> Input = "1-1234567-8"
Assign Activity -> parts = Input.Split("-"c)
Assign Activity -> Prefix = parts(0)
Assign Activity -> ID = parts(1)
Assign Activity -> VerificationNumber = parts(2)
FLOW:
VARIABLE DATATYPE:
OUTPUT:
Regards
postwick
(Paul Ostwick)
8
The resulting array is 0 index, so getting the element with index 1 is the second element IDNumber and the first element is index 0 prefix.
adiijaiin
(Aditya Jain)
9
Hi @Rodrigo_Martinez
Welcome to the Community!
You can split it using
yourVariable.Split(“-”,2)
It will split your data in 2 tokens by using hyphen(-) as delimeter.
Screenshot for reference. My variable name is Name.

e
Happy Automation! 
adiijaiin
(Aditya Jain)
10
Hi @Rodrigo_Martinez
And if you’re trying to generate a DataTable based on
Then Use Generate DataTable Activity with “-” as Column Separators and Newline as Newline separators.
Thanks
Happy Automation! 
Hi everyone.
Thank you all for your help.
I forgot to mention that i was working with C#.
I had to use an assign activity like this:
Prefix: ID.Split(‘-’ , System.StringSplitOptions.None)[0]
IDNumber: ID.Split(‘-’ , System.StringSplitOptions.None)[1]
VerificationNumber: ID.Split(‘-’ , System.StringSplitOptions.None)[2]
Now it’s a happy automation indeed.
Regards,
system
(system)
Closed
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.