Characters[string] gives a list of characters in a string and
StringJoin[ list] returns a string from the specified set of characters.
In[8]:=
Characters[ "abcdefg"]
Out[8]
In[9]:=
Out[9]
The ASCII character codes for each character can be obtained from
StringJoin[ %]
ToCharacterCode[ string]
and the string form of a list of character codes is obtained using
FromCharacterCode. These functions are useful is manipulating strings
to perform arithmetic operations on them.
Additional functions that are useful for String manipulation are the
following.
StringLength[ s] Gives the number of characters in s.
StringTake[ s,k] Gives the first k characters of s.
StringTake[ s, {k,l}] Gives the characters from positions k through l.
StringPosition[ s, t] Gives a list of position where string t occurs in string
s.
StringDrop[ s, {k,l}] Returns a string with the characters from positions k
through l of
s removed.
Strings can be joined using StringJoin[ s1,s2] or s1<>s2.
StringReplace[ s, { s1->t1,....}] will replace all occurrences of s1 by t1
in s.
We illustrate these with the following examples.
Shift Cipher:
Up to Procedural Programming
Frequency Analysis: