UNPKG

@dpatt/delimiterized-regex-builder

Version:

Generate a regex from an array of strings to match all of the strings in order, separated by a delimiter.

19 lines (18 loc) 643 B
/** * Escape special characters in a string to use in a regular expression * @param string * @returns string with escaped characters */ export declare function escapeRegExp(string: string): string; export declare enum DelimiterEnum { wildcards = ".*", whitespace = "[\\s\\n]+", or = "|" } /** * Generate a regex from an array of strings to match all of the strings, in order, separated by a delimiter * @param array * @param delimiter - the delimiter to use between the strings. Defaults to whitespace * @returns regex */ export declare function generateRegexFromArray(array: string[], delimiter?: DelimiterEnum): RegExp;