index.js
function createPattern(pattern, flags) {

    pattern = pattern.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");

    return flags
         ? new RegExp(pattern, flags)
         : new RegExp(pattern);

}
function createPattern(pattern, flags) {

    pattern = pattern.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");

    return flags
         ? new RegExp(pattern, flags)
         : new RegExp(pattern);

}
创建一个正则表达式

@inner
@param {string} pattern
@param {string} flags
@return {RegExp}