type CreateWordBoundaryRegexOptions = { /** * A flag indicating whether to avoid using word boundaries in the regular expression. * If true, the resulting regex will not use word boundaries, which is useful for languages like Chinese and Japanese that do not use spaces between words. */ shouldAvoidUsingWordBoundary?: boolean; /** * A flag indicating whether to match plural forms of the patterns. * If true, the resulting regex will match both singular and plural forms of the patterns. */ shouldMatchPlural?: boolean; }; /** * Creates a regular expression that matches any of the provided patterns with optional word boundaries and plural forms. * * @param {string[]} patterns - An array of string patterns to be included in the regular expression. * @param {CreateWordBoundaryRegexOptions} options - Options for creating the regular expression. * @param {boolean} [options.shouldAvoidUsingWordBoundary=false] - A flag indicating whether to avoid using word boundaries in the regular expression. * @param {boolean} [options.shouldMatchPlural=false] - A flag indicating whether to match plural forms of the patterns. * * @returns {RegExp} - A regular expression that matches any of the provided patterns. If the input patterns array is empty or invalid, returns a regular expression that never matches anything. * * @remarks * - If `shouldAvoidUsingWordBoundary` is `true`, the resulting regular expression will not use word boundaries, which is useful for languages like Chinese and Japanese that do not use spaces between words. * - If `shouldAvoidUsingWordBoundary` is `false`, the resulting regular expression will use word boundaries to match whole words only. * - If `shouldMatchPlural` is `true`, the resulting regular expression will match both singular and plural forms of the patterns. * - Special characters in the patterns are escaped to ensure they are treated as literal characters in the regular expression. * - Patterns are sorted by length in descending order to prioritize longer matches. * - The resulting regular expression is case-insensitive. * - If an error occurs during the creation of the regular expression, a regular expression that never matches anything is returned. * * @throws Will log an error and return an empty regex if there is an error in creating the regex. * @example * // Returns /\b(foo|bar|baz)\b/gi * createWordBoundaryRegex(['foo', 'bar', 'baz']); * * @example * // Returns /(foo|bar|baz)/giu * createWordBoundaryRegex(['foo', 'bar', 'baz'], { shouldAvoidUsingWordBoundary: true }); * * @example * // Returns /\b(foo|bars?|baz)\b/gi * createWordBoundaryRegex(['foo', 'bar', 'baz'], { shouldMatchPlural: true }); */ export declare const createWordBoundaryRegex: (patterns: string[], { shouldAvoidUsingWordBoundary, shouldMatchPlural, }?: CreateWordBoundaryRegexOptions) => RegExp; export {};