Split number into different parts

I have a string which contains only numbers: “4000124872345678”. I want to split it into an array. Each element contains 4 numbers(or characters): array(0)=“400”,array(1)=“1248”, array(3)=“7234” and array(4)=“5678”. How to do that?

1 Like

Hi @hemanth_chinna,

Use this code to get the data array
System.Text.RegularExpressions.Regex.Split("4000124872345678", "(?<=\G.{4})")

using write line activity to print the splited data
string.Join(",",System.Text.RegularExpressions.Regex.Split("4000124872345678", "(?<=\G.{4})"))


1 Like

Hi @arivu96… how to do if we want to split in different size. like one element contain first 4 and second element contain next 6 digits , then how to do.

Hello @Teja_L
one method would be to convert the int to string and split it according to your condition & assign a new variable for it
like this Main.xaml (8.7 KB)

. Where is 4 the. in output 123 and 567890 only… where is digit 4.

for this the output as
image .

hello @Teja_L we have chosen 4 as a separator.
do one thing use this Substring method it will be easy for you to implement