How to Split one string to two Strings?

Hi guys,

How to split String ?
The String format is below
bb/aa

I want to take output
aa
bb

Best Regards;
LwinMoeAung

Buddy,
@Lwin_Moe_Aung

  1. Store that value in variable as variable_1

2…Use split string in assign activity like
To get aa
Variable_bb = varibable_1.split(‘/’)(0)
Variable_aa = variable_1.split('/)(1)

Cheers

1 Like

HI @Lwin_Moe_Aung

You can split using the below command

StrVariable.Split("/"c)

This will generate a string array.
Then you can loop through the array using For Each activity.

Let know whether this helps.

If it does, please make sure to mark my answer as the solution too… :slight_smile:

4 Likes

Thanks you for your rapid reply …

Now,I am facing this error…Can you help me?

Best regards,

Hi … yes… You cave to assign it to an array variable. You are trying assign an array to a string variable. That’s why you are getting the error.

So under the TO segment of the assign activity, clear the text there, and press Ctrl + K to enable variable creation mode, type the variable name there and press enter. THen under variables panel, change the data type of the variable to string array. Under array, select string.

It will work :slight_smile:

After Split() you need to specify which string in this string array to be copied to the left variable. For example, if b = ‘1/2’,a = b.Split('/'c)(1),then a=2.

1 Like

Change the variable as string[ ] and initialize with default value new array[1]

Hi @Lwin_Moe_Aung again!!

Just thought of adding a screenshot of a sample workflow for you…

3 Likes

I got it bro…:smiley:
Thanks you all.
But I have some question that I want to know to get knowledge…

When I tested @Palaniyappan solution I got this error.Why did that happen?


Best regards

1 Like

strSeminarMailName.Split("/")(0).ToString

This will work in his code :slight_smile:

Buddy @Lwin_Moe_Aung use like
Variablename.split(‘/’)(0).tostring
Or
Try like
Split(variablename,‘/’)(0).Tostring

Either would work buddy
Cheers

1 Like

Thanks to all for explanation


When I tested ,this error appear.:sweat:

I got it with this
strSeminarMailName.Split(Convert.ToChar(“/”))(0).ToString.

1 Like

As @Lahiru.Fernando showed above, you can substitute the shorthand "/"c in place of Convert.ToChar(“/”) inside the Split method. It makes the whole statement a bit shorter and easier to read.

2 Likes

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