Replace Specify what to replace and what to replace with Replacement does not have to be the same length s1.replace(0, 5, s2); replace first five characters with s2 s1.replace(3, 1, 10, '*'); replace fourth character with 10 *s