matchTemplates()function

matchTemplates(templates: Iterable<string> & NotString, target: string): TemplateMatches | undefined
ParamType
templatesIterable<string> & NotString
Iterable of template strings to try in order, e.g. [":name-:age", ":name"]. required
targetstring
The string containing values, e.g. Dave-40. required
Return
TemplateMatches | undefined
An object of values for the first matching template, or undefined if none match.

Match multiple templates against a target string and return the first match (no separator semantics).

Examples

matchTemplates([":name-:age", ":name"], "Dave-40") // { name: "Dave", age: "40" }