UNPKG

match-array

Version:

Returns an array of all found named groups matched with given RegExp and string.

25 lines 758 B
/** @module match-array */ declare module "match-array" { /** * Returns all matches of given named groups from a RegEx expression * @example * import matchArray from "match-array" * const result = matchArray(/start +(?<id>[A-Za-z]+)(-(?<suffixNumber>\d+))? +end/g, " start word end\nstart no match here end\nstart nextword-2 end") * result === [ * { * id: "word", * suffixNumber: null, * }, * { * id: "nextword", * suffixNumber: "2", * }, * ] * @function * @param {Regexp} regexExpression * @param {string} targetString * @returns {Object[]} */ export default function(regexExpression: Regexp, targetString: string): object[]; }