JavaScript RegExp返回值是否在各个方括号之间?如何获得价值支架?
使用索引为0,1….N的正则表达式获取不带括号的值。以下是代码-
示例
var regularExpression= /(?<=\[).*?(?=\])/g;
var getTheValueWithIndex= "[John Smith][David
Miller]".match(regularExpression);
console.log("The first value without bracket="+getTheValueWithIndex[0]);
console.log("The second value without
bracket="+getTheValueWithIndex[1]);要运行以上程序,您需要使用以下命令-
node fileName.js.
在这里,我的文件名为demo132.js。
输出结果
这将产生以下输出-
PS C:\Users\Amit\JavaScript-code> node demo132.js The first value without bracket=John Smith The second value without bracket=David Miller
热门推荐
10 过年红包祝福语简短霸气
11 对爸爸的简短祝福语
12 开锁祝福语简短走心
13 搞笑英译祝福语简短句
14 元旦英文祝福语大全简短
15 姐妹生日祝福语女孩简短
16 婆婆去世的祝福语简短
17 父亲婚礼祝福语经典简短
18 结婚祝福语 暖心简短