On this page
  1. String.replaceAll
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

String.replaceAll

Prev: includes | Up: String | Next: trim
Rel: String, String, RegExp & Intl Guide
Ref: MDN Web Docs — String.replaceAll
Tags: #public #web #javascript #builtins #string #tier/core


Signature & Overview

str.replaceAll(pattern, replacement)

Replaces all occurrences of a string or global RegExp (/g) without mutating str.

Notes & Pitfalls

Example

console.assert("a-b-c".replaceAll("-", "_") === "a_b_c");

Linked from

Related notes