{"id":13447195,"url":"https://github.com/laktek/extract-values","last_synced_at":"2025-03-21T17:30:57.501Z","repository":{"id":4913205,"uuid":"6069505","full_name":"laktek/extract-values","owner":"laktek","description":"A simple helper to extract values from a string based on a pattern.","archived":true,"fork":false,"pushed_at":"2016-06-29T20:30:22.000Z","size":19,"stargazers_count":305,"open_issues_count":2,"forks_count":22,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-11T16:42:49.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"wooga/eredis","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laktek.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-04T01:52:42.000Z","updated_at":"2025-01-02T01:13:56.000Z","dependencies_parsed_at":"2022-08-25T17:03:07.830Z","dependency_job_id":null,"html_url":"https://github.com/laktek/extract-values","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laktek%2Fextract-values","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laktek%2Fextract-values/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laktek%2Fextract-values/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laktek%2Fextract-values/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laktek","download_url":"https://codeload.github.com/laktek/extract-values/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244838082,"owners_count":20518781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:10.653Z","updated_at":"2025-03-21T17:30:57.179Z","avatar_url":"https://github.com/laktek.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"## ExtractValues\n\nThis is a simple helper to extract values from a string based on a pattern.\n\n### Examples\n\n```javascript\n\n    extractValues(\"/2012/08/12/test.html\", \"/{year}/{month}/{day}/{title}.html\")\n    \u003e\u003e { \"year\": \"2012\", \"month\": \"08\", \"day\": \"12\", \"title\": \"test\" }\n\n    extractValues(\"John Doe \u003cjohn@example.com\u003e (http://example.com)\", \"{name} \u003c{email}\u003e ({url})\")\n    \u003e\u003e {\"name\": \"John Doe\", \"email\": \"john@example.com\", \"url\": \"http://example.com\" }\n\n    extractValues(\"from 4th October  to 10th  October\", \"from `from` to `to`\", { whitespace: 1, delimiters: [\"`\", \"`\"] })\n    \u003e\u003e {\"from\": \"4th October\", \"to\": \"10th October\" }\n\n    extractValues(\"Convert 1500 Grams to Kilograms\", \"convert {quantity} {from_unit} to {to_unit}\", { lowercase: true })\n    \u003e\u003e {\"quantity\": \"1500\", \"from_unit\": \"grams\", \"to_unit\": \"kilograms\" }]\n\n```\n\n### How to Use\n\n#### Install as a NPM package\n\n```\n    npm install extract-values\n```\n\n* Then `require` in your project.\n    \n```javascript\n    var extractValues = require(\"extract-values\");\n```\n\n#### Use with web apps (in Browser)\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003cscript type=\"text/javascript\" src='extract_values.js'\u003e\u003c/script\u003e\n    \u003cscript type=\"text/javascript\"\u003e\n        var parsedDate = extractValues(\"/2012/08/12/test.html\", \"/{year}/{month}/{day}/{title}.html\")\n        //{ \"year\": \"2012\", \"month\": \"08\", \"day\": \"12\", \"title\": \"test\" }\n    \u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Unit Tests\n\nRun `node tests.js`.\n\n```shell\n$ node tests.js\n14 tests pass\n```\n\n### Options\n\n**whitespace** - normalizes the whitespace in the input string, so it can be aligned with the given pattern. You can define the number of continous whitespaces to contain in the string. Making it zero (0) will remove all whitespaces.\n\n**lowercase** - converts the input string to lowercase before matching.\n\n**delimiters** - If specify the delimiters used in the pattern to define the values. Default delimiters are `{` and `}`.\n\n### Licence\n\n[MIT LICENSE](https://github.com/laktek/punch/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaktek%2Fextract-values","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaktek%2Fextract-values","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaktek%2Fextract-values/lists"}