0
$\begingroup$

I wold like some help of converting an input (word or number or mix) into a single row vector, such as the following:

If input is ">DAVID123<" I want it to be as {>,D,A,V,I,D,1,2,3,<}

where all letters considered as unknown variables.

$\endgroup$
2
$\begingroup$

Try

ToExpression[Select[Characters[">DAVID123<" ],StringMatchQ[#,LetterCharacter]&]]

which will give you a vector of

{D,A,V,I,D}

as symbols or variables, but C and D and E and I and K have predefined meaning inside of Mathematica and may cause you grief.

$\endgroup$
  • $\begingroup$ what about the < and > can I convert them into 0 ? Also where are the numbers {1,2,3} ? $\endgroup$ – Love Eva Sep 17 at 6:39
  • $\begingroup$ This ToExpression[Characters[StringReplace[">DAVID123<",PunctuationCharacter:>"0"]]] gives you `{0,D,A,V,I,D,1,2,3,0} $\endgroup$ – Bill Sep 17 at 8:06

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.