g.js — graphical objects for JavaScript

stringReplacestringReplace

Replace part of a string.

g.stringReplace('Hello', 'e', 'a');

The stringReplace function replaces all occurrences of one substring with another one:

g.stringReplace('Vickie Daisie', 'ie', 'y');

Parameters

  • s: The input string.
  • old: The old substring to replace.
  • new: The replacement string.