6

I have an string "000101".

I know that Characters change it to {"0","0","0","1","0","1"}.

I want to move over this list and read its member as integer numbers. How can i do this?

Thanks a lot

Kuba
  • 136,707
  • 13
  • 279
  • 740
A. Mpi
  • 429
  • 2
  • 7

3 Answers3

7
v = ToExpression /@ StringSplit["000101", ""]

yields:

{0,0,0,1,0,1}

ToExpression["000101"]

yields:

101
ubpdqn
  • 60,617
  • 3
  • 59
  • 148
5

Assuming there are only digits in a string:

ToCharacterCode["123456789"] - 48

or

"123456789" // StringCases[i : DigitCharacter :> ToExpression[i]]

or

"123456789" // Characters // ToExpression
Kuba
  • 136,707
  • 13
  • 279
  • 740
3
FromDigits /@ Characters @ "000101"

{0, 0, 0, 1, 0, 1}

kglr
  • 394,356
  • 18
  • 477
  • 896