TypeScript replace String that matches a particular text code example
Example 1: replace string in typescript
var re = /apples/gi;
var str = "Apples are round, and apples are juicy.";
var newstr = str.replace(re, "oranges");
console.log(newstr)
Example 2: string one char change in typescript
let hello:string = "Hello World";
console.log(hello.replaceAt(2, "!!")); // Should display He!!o World