getMatch()function
getMatch(str: string, regexp: NamedRegExp<T>): NamedRegExpExecArray<T> | undefined
getMatch(str: string, regexp: TypedRegExp<T>): TypedRegExpExecArray<T> | undefined
getMatch(str: string, regexp: RegExp): RegExpExecArray | 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 | TypedRegExp<T> | Regular expression that matches a specific string format. required |
regexp | RegExp | required |
| Return | |
|---|---|
NamedRegExpExecArray<T> | undefined | The match array, or undefined if the string did not match. |
TypedRegExpExecArray<T> | undefined | |
RegExpExecArray | undefined |
Get an optional regular expression match, or undefined if no match could be made.
Examples
getMatch("abc", /b/); // ["b"]