requireMatchGroups()function
requireMatchGroups(str: string, regexp: NamedRegExp<T>): T
requireMatchGroups(str: string, regexp: RegExp): NamedRegExpData
| Param | Type | |
|---|---|---|
str | string | String to match against the regular expression. required |
regexp | NamedRegExp<T> | Regular expression to match against the string. required |
str | string | required |
regexp | RegExp | required |
| Return | |
|---|---|
T | The set of named match groups. |
NamedRegExpData | Set of named match groups from a regular expression. |
| Throws | |
|---|---|
ValueError | If the string did not match the regular expression. |
Get the named groups of a required regular expression match, or throw ValueError if no match could be made.
Examples
requireMatchGroups("abc", /(?<first>a)/); // { first: "a" }