小编Jul*_* TF的帖子

是否可以修改现有RegExp上的标志?

我的代码收到一个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 不是一件事

有一个更好的方法吗?

javascript regex

11
推荐指数
2
解决办法
387
查看次数

node-gyp的[选项]在哪里记录?

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)

node-gyp

7
推荐指数
1
解决办法
3218
查看次数

标签 统计

javascript ×1

node-gyp ×1

regex ×1