regex-iterator
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

regex-iterator

npm build coverage

string matching iterator using regular expression

Changelog

Install

# using npm 
npm install --save regex-iterator
 
# using yarn 
yarn add regex-iterator

Usage

import * as regex_iterator from 'regex-iterator';
 
const spread_sample = () => {
  const iterator = regex_iterator.create(/([0-9])([a-z])/g, '1a 2b 3c');
  return [...iterator]; //=> [['1a', '1', 'a'], ['2b', '2', 'b'], ['3c', '3', 'c']]
};
 
const take_sample = () => {
  const iterator = regex_iterator.create(/([0-9])([a-z])/g, '1a 2b 3c');
  return regex_iterator.take(
    iterator,
    match => match[2] !== 'c',
    match => `${match[1]}-${match[2]}`,
  ); //=> ['1-a', '2-b']
};

Development

# lint 
yarn run lint
 
# build 
yarn run build
 
# test 
yarn run test

License

MIT © Ika

Package Sidebar

Install

npm i regex-iterator

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • ikatyang