strings-and-tokens
v1.0.2
Published
A string manipulation library
Downloads
2
Readme
Strings and tokens
A module for working with strings.
Installation
npm install --save strings-and-tokens
Usage
var strings = require('strings-and-tokens');
var pattern = strings.tokens.createPattern('{name}@{domain}.{ext[3]}');
console.log(strings.tokens.parse('[email protected]'), pattern); // {name: 'example', domain: 'example': ext: 'com'}
or
var strings = require('strings-and-tokens');
console.log(strings-and-tokens.parsers.email('[email protected]'));
You could also tokenize a string.
var strings = require('strings-and-tokens');
console.log(strings.tokens.tokenize('Good afternoon!'));
This gives an array of words. A word is an object like:
{
type: 'string' or 'number',
value: string or number,
line: number
column: number
}
Testing
npm test
Requires mocha and Unexpected.