“JavaScript Regex REPLACE” Kode Jawaban

Ganti semua kemunculan string di JavaScript

const p = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?';

console.log(p.replaceAll('dog', 'monkey'));

// expected output: "The quick brown fox jumps over the lazy monkey. If the monkey reacted, was it really lazy?"



Batman

JavaScript Regex REPLACE

const search = 'duck'
const replaceWith = 'goose';

const result = 'duck duck go'.replaceAll(search, replaceWith);

result; // => 'goose goose go'
Powerful Penguin

str ganti javascript semuanya

str.replace(/abc/g, '');
Amin :)

Ganti semua JavaScript

str.split(search).join(replacement);
Strange Shrew

Jawaban yang mirip dengan “JavaScript Regex REPLACE”

Pertanyaan yang mirip dengan “JavaScript Regex REPLACE”

Lebih banyak jawaban terkait untuk “JavaScript Regex REPLACE” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya