Javascript String Quote String via Regex and replace()

Description

Javascript String Quote String via Regex and replace()


let myString = "Both Java and JavaScript share the same name, but are quite different.";
let myRegexp = /Java(Script)?/g;

console.log( myString.replace(myRegexp, "'$&'"));



PreviousNext

Related