getMatchGroups()function
getMatchGroups(str: string, regexp: NamedRegExp<T>): T | undefined
getMatchGroups(str: string, regexp: RegExp): NamedRegExpData | undefined
| 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 | undefined | The set of named match groups, or undefined if the string did not match. |
NamedRegExpData | undefined |
Get the named groups of an optional regular expression match, or undefined if no match could be made.
Examples
getMatchGroups("abc", /(?<first>a)/); // { first: "a" }