In this video, we are discussing How to replace a character,a substring or group of characters from a string variable in javascript
1. Replace a character from a variable with empty character
2.Replace a sub string from a variable with empty character
3.Replace a set of characters from a variable with empty character
Here we replace character 'e' from string 'Technursery' by calling blogName.replace('e', '') .It will replace first occurrence of 'e' from the string 'Technursery'
const blogName = 'Technursery';
const blogNameWithoutVowels = blogName.replace('e', '');
console.log(blogNameWithoutVowels);
Here we are replacing all vowels characters aeiou from the given string using regular expression REGEX.By executing blogName.replace(/[aeiou]/gi, '') we will get the string without all vowels aeiou
const blogName = 'Technursery';
const blogNameWithoutVowels = blogName.replace(/[aeiou]/gi, '');
console.log(blogNameWithoutVowels);
Here we replace a substring with empty string in javascript. When we execute blogName.replace('Tech', '') it will replace substring Tech with empty string
const blogName = 'Technursery';
const blogNameWithoutVowels = blogName.replace('Tech', '');
console.log(blogNameWithoutVowels);
Watch video Replace string in javascript with examples including regular expression REGEX online without registration, duration hours minute second in high quality. This video was added by user Tech Nursery 21 January 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 109 once and liked it 1 people.