StringInsert

StringInsert["string","snew",n]

yields a string with "snew" inserted starting at position n in "string".

StringInsert["string","snew",-n]

inserts at position n from the end of "string".

StringInsert["string","snew",{n1,n2,}]

inserts a copy of "snew" at each of the positions n_(i).

StringInsert[{s1,s2,},"snew",n]

gives the list of results for each of the s_(i).

Details

  • StringInsert["string","snew",n] makes the first character of snew the n^(th) character in the new string.
  • StringInsert["string","snew",-n] makes the last character of snew the n^(th) character from the end of the new string.
  • In StringInsert["string","snew",{n1,n2,}] the ni are taken to refer to positions in "string" before any insertion is done. »

Examples

open allclose all

Basic Examples  (1)

Insert "XYZ" after character position 4:

In[1]:=
Click for copyable input
Out[1]=

Scope  (2)

Applications  (1)

Properties & Relations  (2)

Possible Issues  (2)

See Also

StringReplacePart  Insert  StringPosition

Tutorials

Introduced in 1991
(2.0)
| Updated in 2004
(5.1)