extract-string
String Pattern extractor for nodejs
Last updated 3 years ago by npm.creador .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install extract-string 
SYNC missed versions from official npm registry.
Build Status Pull Requests stats NPM Downloads NPM Version

Extract-String

Extracts the given pattern variables from the given string. You can use it to extract url params and strings without using regex.

Installation

npm install extract-string --save

Then, in your app:

var extract = require('extract-string');

Example 1

var test = extract('Hello my friends of the world.\nHello my dear friends of this world.')
			.pattern('{hi} my {type} of {where}.');

/*
returns:
[{
	hi : 'Hello',
	type : 'friends',
	where : 'the world'
},
{
	hi : 'Hello',
	type : 'dear friends',
	where : 'this world'
}
]
*/

Example 2

var test = extract('/users/12345/friends/6789/picture')
			.pattern('/users/{userid}/friends/{friendid}/picture');
/*
returns:
[{
	userid : 12345,
	friendid : 6789
}]
*/

License

MIT

Current Tags

  • 1.0.2                                ...           latest (3 years ago)

3 Versions

  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |