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 长寿老人送礼祝福语简短