Replace words
PYTHON is one of the world’s most popular programming languages. In fact, it’s more so than ever. Python is also one of the most popular choices of backend programming. It is relatively new and has enormous library support.
Replace only the first word (=default) - case sensitive (=default)
PYTHON is one of the world’s most popular scripting languages. In fact, it’s more so than ever. JavaScript is also one of the most popular choices of backend programming. It is relatively new and has enormous library support.
Replace only the first word (=default) - case insensitive
JavaScript is one of the world’s most popular scripting languages. In fact, it’s more so than ever. Python is also one of the most popular choices of backend programming. It is relatively new and has enormous library support.
Replace globally - case sensitive (=default)
PYTHON is one of the world’s most popular scripting languages. In fact, it’s more so than ever. JavaScript is also one of the most popular choices of backend scripting. It is relatively new and has enormous library support.
Replace globally - case insensitive
JavaScript is one of the world’s most popular scripting languages. In fact, it’s more so than ever. JavaScript is also one of the most popular choices of backend scripting. It is relatively new and has enormous library support.
const original = document.getElementById('original').innerHTML;
// Replace only the first word (=default) - case sensitive (=default)
const replace1 = document.getElementById('replace1');
replace1.innerHTML = original.replace('Python', 'JavaScript').replace('programming', 'scripting');
// Replace only the first word (=default) - case insensitive
const replace2 = document.getElementById('replace2');
replace2.innerHTML = original.replace(/Python/i, 'JavaScript').replace(/programming/i, 'scripting');
// Replace globally - case sensitive (=default)
const replace3 = document.getElementById('replace3');
replace3.innerHTML = original.replace(/Python/g, 'JavaScript').replace(/programming/g, 'scripting');
// Replace globally - case insensitive
const replace4 = document.getElementById('replace4');
replace4.innerHTML = original.replace(/Python/gi, 'JavaScript').replace(/programming/gi, 'scripting');