Skip to content

@technobuddha > library > Object > Type Guards

Function: isRegExp()

ts
function isRegExp(value: unknown): value is RegExp;

Defined in: is-reg-exp.ts:18

Determines whether the provided value is a RegExp object.

Parameters

ParameterTypeDescription
valueunknownThe value to test.

Returns

value is RegExp

true if the value is a RegExp object; otherwise, false.

Example

typescript
isRegExp(/abc/); // true
isRegExp(new RegExp('abc')); // true
isRegExp('abc'); // false
isRegExp({}); // false
isRegExp(null); // false