Docs (4.0.0)
class Assertion method

toMatchRegExp

Asserts that the value is a string that matches given regular expression.

toMatchRegExp(re: RegExp): void

Note
The assertion fails if the value is not a string. Use the asString() method to convert the value first if needed.

Example

// this succeeds:
let s = "foo";
expect(s).toMatchRegExp(/o+/);

Related