function hasNativeFlag(flag) {
    // Can't check based on the presence of properties/getters since browsers might support such
    // properties even when they don't support the corresponding flag in regex construction (tested
    // in Chrome 48, where `'unicode' in /x/` is true but trying to construct a regex with flag `u`
    // throws an error)
    var isSupported = true;
    try {
        // Can't use regex literals for testing even in a `try` because regex literals with
        // unsupported flags cause a compilation error in IE
        new RegExp('', flag);
    } catch (exception) {
        isSupported = false;
    }
    return isSupported;
}
XRegExp provides augmented, extensible regular expressions. You get additional regex syntax and
flags, beyond what browsers support natively. XRegExp is also a regex utility belt with tools to
make your client-side grepping simpler and more powerful, while freeing you from related
cross-browser inconsistencies.