123456789101112131415161718192021 |
- var toString = Object.prototype.toString;
- function isRegExp (o) {
- return 'object' == typeof o
- && '[object RegExp]' == toString.call(o);
- }
- module.exports = exports = function (regexp) {
- if (!isRegExp(regexp)) {
- throw new TypeError('Not a RegExp');
- }
- var flags = [];
- if (regexp.global) flags.push('g');
- if (regexp.multiline) flags.push('m');
- if (regexp.ignoreCase) flags.push('i');
- return new RegExp(regexp.source, flags.join(''));
- }
|