requireMatch()function
requireMatch(str: string, regexp: NamedRegExp<T>): NamedRegExpExecArray<T>
requireMatch(str: string, regexp: TypedRegExp<T>): TypedRegExpExecArray<T>
requireMatch(str: string, regexp: RegExp): RegExpExecArray
| 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> | The match array. |
TypedRegExpExecArray<T> | Regular expression match array whose full match is a specific string format. |
RegExpExecArray |
| Throws | |
|---|---|
ValueError | If the string did not match the regular expression. |
Get a required regular expression match, or throw ValueError if no match could be made.
Examples
requireMatch("abc", /b/); // ["b"]