我的代码收到一个RegExp对象(不受我的控制).它不是全球性的,但我需要它.
目前我正在这样做:
if (!regex.global) {
var flags = 'g';
if (regex.ignoreCase) flags += 'i';
if (regex.multiline ) flags += 'm';
if (regex.sticky ) flags += 'y';
regex = new RegExp(regex.source, flags);
}
Run Code Online (Sandbox Code Playgroud)
...因为我无法弄清楚任何其他方式.
regex.global 没有二传手. regex.compile(new_pattern) 不赞成使用 new RegExp(new_pattern)regex.flags 不是一件事有一个更好的方法吗?
node-gyp --help 说:
Usage: node-gyp <command> [options]
where <command> is one of:
- build - Invokes `make` and builds the module
- clean - Removes any generated build files and the "out" dir
- configure - Generates a Makefile for the current module
- rebuild - Runs "clean", "configure" and "build" all at once
- install - Install node development files for the specified node version.
- list - Prints a listing of the currently installed node development files
- …Run Code Online (Sandbox Code Playgroud)