I found some formulas on the web but since the number of digits is not equal in the cells, I can't get the result I need.

For example, in column A:

12345

12

135789

135

etc.

What formula can give me the result I need? can I get some help, please? thanks.

Expected results of the above example:

1,2,3,4,5

1,2

1,3,5,7,8,9

1,3,5