@hitsuji_no_shippo/extract-matching-values-in-patterns
v0.1.0
Published
Extract values that match the pattern.
Downloads
25
Readme
= README :author-name: hitsuji no shippo :!author-email: :author: {author-name} :!email: {author-email} :revnumber: v1.0.0 :revdate: 2019-11-26T23:02:13+0900 :revremark: First Edition :doctype: article :description: extract-maching-values-in-patterns README :title-separtor: : :showtitle: :!sectnums: :sectids: :!toc: :sectlinks: :sectanchors: :idprefix: :idseparator: - :xrefstyle: full :!example-caption: :!figure-caption: :!table-caption: :!listing-caption: ifdef::env-github[] :caution-caption: :fire: :important-caption: :exclamation: :note-caption: :paperclip: :tip-caption: :bulb: :warning-caption: :warning: endif::[] ifndef::env-github[:icons: font] // Copyright :copyright-template: Copyright (c) 2019 :copyright: {copyright-template} {author-name} :code-license: MIT :document-license: CC BY-NC-SA 40 // Page Attributes :page-creation-date: 2019-11-26T23:02:13+0900 // Variables
.Installation [source, bash]
npm install --save @hitsuji_no_shippo/extract-matching-values-in-patterns
When the string matches pattern, the value set in pattern is extracted.
.Example [source, JavaScript]
const extractMatchingValuesInPatterns = require(@hitsuji_no_shippo/extract-matching-values-in-patterns
);
const str = 'abc/def/ghi';
const patterns = {
abc: {
values: {
abc: 'abc',
},
patterns: {
def: {
values: {
nestDef: 'nestDef',
},
},
ghi: {
values: {
ghi: 'ghi',
},
},
jkl: {
values: {
jkl: 'jkl',
},
},
},
},
def: {
values: {
def: 'def',
},
},
xyz: {
values: {
xyz: 'xyz',
},
},
'^abc': {
values: {
'^abc': 'abc',
},
},
};
extractMatchingValuesInPatterns(str, patterns);
.Result [source, JavaScript]
{ abc: 'abc', nestDef: 'nestDef', ghi: 'ghi', def: 'def', '^abc': 'abc' }
== Copyright
.LICENSE This document is licensed under {document-license}
{copyright-template} link:https://hitsuji-no-shippo.com[{author-name}]