@valtech-commerce/capturing-group-values

1.0.0 • Public • Published

@valtech-commerce/capturing-group-values

npm npm dependencies npms Travis CI

Extracts capturing group values via a regular expression

Install

$ npm install @valtech-commerce/capturing-group-values

Usage

import capturingGroupValues from '@valtech-commerce/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 © Valtech Canada inc.

Readme

Keywords

Package Sidebar

Install

npm i @valtech-commerce/capturing-group-values

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.85 kB

Total Files

5

Last publish

Collaborators

  • valtech_commerce_ci
  • jblandry
  • valtech_commerce