regex-iterator
v1.0.0
Published
string matching iterator using regular expression
Downloads
2
Maintainers
Readme
regex-iterator
string matching iterator using regular expression
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