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 婚前女儿生日祝福语简短