Skip to content

creador/patternParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

nodejs extract pattern struct from string

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published