String.prototype.replaceAll() not working [duplicate]

Update: All recent versions of major browsers, as well as NodeJS 15+ now support replaceAll

Original:

There is no replaceAll in JavaScript: the error console was probably reporting an error.

Instead, use the /g (“match globally”) modifier with a regular expression argument to replace:

const a = "::::::";
const replaced = a.replace(/:/g,"hi");
console.log(replaced);

The is covered in MDN: String.replace (and elsewhere).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)