This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## ExtractValues | ||
|
||
This is a simple helper to extract values from a string based on a pattern. | ||
|
||
### Examples | ||
|
||
```javascript | ||
|
||
extractValues("/2012/08/12/test.html", "/{year}/{month}/{day}/{title}.html") | ||
>> { "year": "2012", "month": "08", "day": "12", "title": "test" } | ||
|
||
extractValues("John Doe <john@example.com> (http://example.com)", "{name} <{email}> ({url})") | ||
>> {"name": "John Doe", "email": "john@example.com", "url": "http://example.com" } | ||
|
||
extractValues"from 4th October to 10th October", "from `from` to `to`", { whitespace: 1, delimeters: ["`", "`"] }]) | ||
>> {"from": "4th October", "to": "10th October" }] | ||
``` | ||
|
||
### How to Use | ||
|
||
* Install as a NPM package | ||
|
||
``` | ||
npm install extract-values | ||
``` | ||
|
||
* Then `require` in your project. | ||
|
||
```javascript | ||
var extractValues = require("extractValues"); | ||
``` | ||
|
||
* For client-side use, simply copy and paste the function (`extract_values.js`) in to your source. | ||
|
||
### Licence | ||
|
||
[MIT LICENSE](https://github.com/laktek/punch/blob/master/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "extract-values", | ||
"description": "A simple helper to extract values from a string based on a pattern.", | ||
"keywords": [ | ||
"regex", | ||
"pattern matching", | ||
"strings" | ||
], | ||
"version": "0.0.1", | ||
"homepage": "https://github.com/laktek/extract-values", | ||
"author": "Lakshan Perera <lakshan@web2media.net> (http://laktek.com)", | ||
"licenses": "MIT", | ||
"bugs": { | ||
"url": "http://github.com/laktek/extract-values/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/laktek/extract-values.git" | ||
}, | ||
"main": "./lib/extract_values.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters