Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

using of replace() in Javascript

let str = "I like to eat, eat, eat apples and bananas";
let re = /apples|bananas/gi;

let newStr = str.replace(re, (match) => { 
    console.log({match}); 
    return match.toUpperCase();
});

console.log(newStr);
Code language: JavaScript (javascript)
Source by www.javascripttutorial.net #
 
PREVIOUS NEXT
Tagged: #Javascript
ADD COMMENT
Topic
Name
7+6 =