JavaScript_Regular_Expression_Methods
JavaScript_Regular_Expression_Methods
string.replace replaces matches string const testString = 'She sells seashells by the seashore';
with fixed string or const regex = /\b(s)\w+\b/gi;
tongueTwister.replace(regex, 's-word');
output of function // 's-word s-word s-word by the s-word’
applied to match
(see below for testString.replace(regex, (match, first_letter) =>
arguments to function) `${first_letter}-word`);
// 'S-word s-word s-word by the s-word'