Function transformAndEnsureRegExpRegExpArray

  • Transforms a string or an array of strings into an array of regular expressions, ensuring that the result is always an array.

    This function accepts a value that may be a single string, an array of strings, or undefined. It then:

    • Converts each string into a RegExp object.
    • If the input is an array containing nested arrays, it converts each string in the nested arrays into RegExp objects.
    • Ensures that the result is always an array of RegExp objects or arrays of RegExp objects.

    Parameters

    • stringStringMaybeArray: undefined | string | (string | string[])[]

      The value to be transformed, which can be a single string, an array of strings or arrays of strings, or undefined.

    Returns (RegExp | RegExp[])[]

    An array of RegExp objects or arrays of RegExp objects. If the input is undefined, an empty array is returned.