yoastseo
Version:
Yoast client-side content analysis
39 lines (36 loc) • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _addWordboundary = _interopRequireDefault(require("../word/addWordboundary.js"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/** @module stringProcessing/createRegexFromDoubleArray */
/**
* Creates a regex string of combined strings from the input array.
*
* @param {array} array The array containing the various parts of a transition word combination.
*
* @returns {array} The array with replaced entries.
*/
const wordCombinationToRegexString = function (array) {
array = array.map(function (word) {
return (0, _addWordboundary.default)(word);
});
return array.join("(.*?)");
};
/**
* Creates a regex of combined strings from the input array, containing arrays with two entries.
*
* @param {array} array The array containing arrays.
*
* @returns {RegExp} The regex created from the array.
*/
function _default(array) {
array = array.map(function (wordCombination) {
return wordCombinationToRegexString(wordCombination);
});
const regexString = "(" + array.join(")|(") + ")";
return new RegExp(regexString, "ig");
}
//# sourceMappingURL=createRegexFromDoubleArray.js.map