6
$\begingroup$

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

$\endgroup$
7
$\begingroup$
v = ToExpression /@ StringSplit["000101", ""]

yields:

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

ToExpression["000101"]

yields:

101
$\endgroup$
5
$\begingroup$

Assuming there are only digits in a string:

ToCharacterCode["123456789"] - 48

or

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

or

"123456789" // Characters // ToExpression
$\endgroup$
3
$\begingroup$
FromDigits /@ Characters @ "000101"

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

$\endgroup$
  • $\begingroup$ Nicer version than what I posted (now deleted) $\endgroup$ – user1066 Jun 26 '17 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.