How to split string by length & by nearest characters

Hello!
How to split string by length of 10 characters and at the nearest comma?
example :
I have a var (string) which contains a list of number divided by commas (ex. 20,26,55,80,100,150).
I need to split it after 10 characters at the nearest “,” so that none of the values will be cut. The values in the variable will always change.

After checking some previous post on this forum, i tried with the following but i get some validation error “Cannot assign from type System.int32” to Type System.string in Assigned activity":

SplitIndex = (My_VAR.Substring(0,10).LastIndexOf(“,”)+1)

I’ve tried to set SplitIndex variable as an array.string, list.string but I get similar error .

Anyone can help with this?

@abuzzi,

From this string, “20,26,55,80,100,150”

what is your expected output?

Thanks!

Hi Kadiravan,

Issue has been fix. Did not realize that .LastIndexOf it returns the index as numerical value so INT32 is required.

It’s working now.

Desired output is to get the string split as below:

20,26,55,
80,100,150

1 Like

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