• Returns whether the given pattern can be compiled to a regex

    Parameters

    • Optionalpattern: null | string

      the pattern to check

    • Optionalflags: string

      any combination of flag values

    Returns boolean

    whether the given pattern can be compiled to a regex

    isCompilable(undefined);    // false
    isCompilable('foobar'); // true
    isCompilable('[a-zA-Z0-9]+', 'g'); // true