@absolunet/capturing-group-values 中文文档教程
@absolunet/capturing-group-values
通过正则表达式
Install
$ npm install @absolunet/capturing-group-values
Usage
import capturingGroupValues from '@absolunet/capturing-group-values';
const pattern = /(?<alpha>[a-z]+)?:(?<num>\d+)?/u;
console.log(capturingGroupValues('', pattern)); // {}
console.log(capturingGroupValues(':', pattern)); // {}
console.log(capturingGroupValues('abc', pattern)); // {}
console.log(capturingGroupValues('123', pattern)); // {}
console.log(capturingGroupValues('abc:xyz', pattern)); // { alpha: 'abc' }
console.log(capturingGroupValues('123:789', pattern)); // { num: '789' }
console.log(capturingGroupValues('abc:789', pattern)); // { alpha: 'abc', num: '789' }
Documentation
视图提取捕获组值 文档
License
MIT © Absolunet
@absolunet/capturing-group-values
Extracts capturing group values via a regular expression
Install
$ npm install @absolunet/capturing-group-values
Usage
import capturingGroupValues from '@absolunet/capturing-group-values';
const pattern = /(?<alpha>[a-z]+)?:(?<num>\d+)?/u;
console.log(capturingGroupValues('', pattern)); // {}
console.log(capturingGroupValues(':', pattern)); // {}
console.log(capturingGroupValues('abc', pattern)); // {}
console.log(capturingGroupValues('123', pattern)); // {}
console.log(capturingGroupValues('abc:xyz', pattern)); // { alpha: 'abc' }
console.log(capturingGroupValues('123:789', pattern)); // { num: '789' }
console.log(capturingGroupValues('abc:789', pattern)); // { alpha: 'abc', num: '789' }
Documentation
View documentation
License
MIT © Absolunet