I want to split a number using regex. I have a number like xyz
(x
and y
are single digits, z
can be a 2 or three digit number), for example 001
or 103
or 112
. I want to split it into separate numbers. This can be done, if I'm not wrong by doing split("",3)
; This will split the number (saved as string, but I don't think it makes difference in this case) 103
in an array with values 1
,0
,3
.
Since here it's easy,the fact is that the last number z
may be a 2 or 3 digit number.
So I could have 1034
, 0001
, 1011
so on. And I have to split it respectively into [1,0,34]
[0,0,01]
[1,0,11]
How can I do that?
Thanks
Sergiu