Function regExpUnion

  • Combines several regular expressions into a new one that matches any of them.

    Time complexity: O(n)

    Space complexity: O(1)

    Parameters

    • ...regExps: RegExp[]

      Regular expressions to get the union of

    Returns RegExp

    A new regular expression

    Regular expressions

    regExpUnion(/[a-z]/, /\d/); // /([a-z])|(\d)/