createRegExpAny()function

createRegExpAny(patterns: Iterable<PossibleRegExp> & NotString, flags?: string): RegExp
ParamType
patternsIterable<PossibleRegExp> & NotString
The regular expressions or string sources to combine. required
flagsstring
The flags to use when creating the combined RegExp.
Return
RegExp
A RegExp that matches if any of the provided expressions match.

Create a regular expression that matches any one of a list of other expressions.

  • If the list is empty the returned expression matches nothing (NEVER_REGEXP).

Examples

createRegExpAny(["abc", "def"]); // /(?:abc)|(?:def)/