gmatch:在JavaScript中方便地全局匹配正则表达式的方法

时间:2021-05-10 18:13:57
【文件属性】:
文件名称:gmatch:在JavaScript中方便地全局匹配正则表达式的方法
文件大小:3KB
文件格式:ZIP
更新时间:2021-05-10 18:13:57
JavaScript Gmatch 当你想在全球范围内匹配的正则表达式,并在同一时间仅返回特定捕获组,好了,你就要有一个。 该模块将帮助您避免编写额外的代码来处理这种不愉快的事情。 安装 npm install --save gmatch 用法 var gmatch = require ( 'gmatch' ) ; var str = 'Return A and B. And return C and D.' ; var pattern = / ( . ) and ( . ) / g ; var matches = gmatch ( str , pattern ) ; console . log ( matches ) ; 输出为: [ [ 'A' , 'B' ] , [ 'C' , 'D' ] ] 但为什么? 结果是: [ 'A and B' , 'C and D' ] 因此根本没有捕获组。 它
【文件预览】:
gmatch-master
----.gitattributes(12B)
----test.js(633B)
----.travis.yml(60B)
----README.md(2KB)
----.editorconfig(188B)
----.gitignore(15B)
----index.js(421B)
----package.json(640B)

网友评论