This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

StringReplacePart

StringReplacePart
replaces the characters at positions m through n in by .
StringReplacePart
inserts copies of at several positions.
StringReplacePart
replaces characters at positions through in by .
  • When a list of is given, its length must be the same as the length of the list of positions. »
  • When multiple positions are given, all refer to the original , before any replacements have been done.
Replace characters 2 through 5 with a new string:
Replace several sequences of characters with a new string:
Replace characters 2 through 5 with a new string:
In[1]:=
Click for copyable input
Out[1]=
 
Replace several sequences of characters with a new string:
In[1]:=
Click for copyable input
Out[1]=
Negative positions count from the end:
Replace two sequences of characters with two new strings:
Simulating a multiway system
The evolution of a multiway system:
StringReplacePart can use the output from StringPosition:
This is equivalent to StringReplace:
Replacing with an empty string is equivalent to StringDrop:
StringReplacePart can drop several sequences of characters at a time:
Use position to insert at position n, without overwriting anything:
StringInsert can do the same:
The position specifications are not allowed to overlap:
New in 3