Split the string, following the rule given below:


#1

We have some string formatted like these,

12345678L5680
11111111B1113
00000000D99999999
10000000L0005B0007L0010D11000000B0002L0005
The string includes numbers and ‘L’ ‘B’ ‘D’.
As you can see, the string starts with a 8-digits number,then followed by a letter.
For letter ‘L’, it means consecutive or “to”, it is folloew by a 4-digits number.
For letter ‘B’,it means inconecutive or “and”, it is folloew by a 4-digits number.
And Letter ‘D’ stands for renew, it is followed by a 8-digits number.
Therefore,
12345678L5680 would be splited into 12345678 to 1234567780(or you can say 12345678,12345679,123456780).
11111111B1113 would be splited into 111111111 and 11111113.
00000000D99999999 would be 00000000 and 99999999.
10000000L0005B0007L0010D11000000B0002L0005
would be splitted into
10000000
10000001
10000002
10000003
10000004
10000005
10000007
10000008
10000009
10000010
11000000
11000002
10000005
The length of the string is not fixxed.
I tryed using array but I was stuck by dynamic array, could you please help me find a better way to solve this?
Many thanks!


#2

hi @HartZhong

Check the below posts


Thanks
Ashwin S