yoastseo
Version:
Yoast client-side content analysis
21 lines (20 loc) • 762 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = searchAndReplaceWithOneRegex;
/**
* Checks whether a given regex matches a given word and if so, performs the replacement.
*
* @param {string} word The word that may need to be modified.
* @param {string[]} regexAndReplacement A regex and the required replacement.
*
* @returns {?string} The modified stem or undefined if no match was found.
*/
function searchAndReplaceWithOneRegex(word, regexAndReplacement) {
if (word.search(new RegExp(regexAndReplacement[0])) !== -1) {
word = word.replace(new RegExp(regexAndReplacement[0]), regexAndReplacement[1]);
return word;
}
}
//# sourceMappingURL=searchAndReplaceWithOneRegex.js.map