Splitting a Number into digits

Hi, how can I read a number, for example 7344, in its specific digits at its specific position? ‘7’ in position 0, ‘3’ in position 1, ‘4’ in position 2, ‘4’ in position 3? I tried using foreach for I’m not sure how to go about doing it.

Do I have to introduce a delimiter to it such as a comma, giving it 7,3,4,4 and then split the number into its digits according to the delimiter?

1 Like

Hi @michaelkid

Welcome to uipath community

create a variable1 of type int32
then create another variable2 of type array of char, that is system.char
then use a assign activity like this
variable2 = variable1.ToString.ToCharArray

thats all buddy you can get the value of each index from variable 2
like in write line activity put like this
variable2(0)
here you go @michaelkid
arrayy.zip (1.9 KB)

like this

Cheers @michaelkid

2 Likes

did that work @michaelkid

1 Like

Yes that did work! Reading the digits at specific positions is working. Thank you so much!

1 Like

Fantastic buddy @michaelkid
Cheers
@michaelkid

1 Like

how do I split them to 2 digits, ie for ex 201908 in to 20 19 08?

1 Like

Hi @Saranyajk

int i = 201908

int a = i / 10000
int b = (i - (a * 10000)) / 100
int c = (i - ((a * 10000) + (b * 100)))

Cool,
Regards,
Gulshiyaa

3 Likes

great! thank you so much

1 Like

what if its a string and if I have to get like 2 characters?