npm.io
0.3.4 • Published 9 years ago

tokenize-monster

Licence
MIT
Version
0.3.4
Deps
0
Vulns
0
Weekly
0

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.

Keywords