tokenize-monster

Yet another powerful tokenizer in js


Keywords
tokenizer, parser, replacer, functional-programming, tokenize
License
MIT
Install
npm install tokenize-monster@0.3.4

Documentation

Tokenize Monster

Yet another powerful tokenizer in JS.

Installation

npm install --save tokenize-monster

Getting Started

const tokenizer = require('tokenize-monster');

const tokens = tokenizer.matchAndMap(
	'i\'d like to <drink> some <milk>',
	/<[^><]+>/,
	text => [[text]],
	text => [text]
);

console.log(tokens);
// => [ 'i\'d like to ', [ '<drink>' ], ' some ', [ '<milk>' ], '' ]

const nTokens = tokenizer.matchAndMap(
	'i\'d like to <drink> some <milk>',
	/<[^><]+>/,
	text => [text],
	text => []
);

console.log(nTokens);
// => [ '<drink>', '<milk>' ]

Example

Documentation

Our docs are available at Tokenize Monster Wiki.

Changelog

Visit Github Releases page for more information.