Skip to content

isRegExp

The isRegExp function checks if the provided value is a regular expression (RegExp).

Syntax

typescript
isRegExp(value: any): value is RegExp;

Parameters

ParameterTypeDescription
valueanyValue to be checked

Returns

TypeDescription
booleanTrue if it is a RegExp

Examples

typescript
isRegExp(/abc/); // => true
isRegExp("abc"); // => false

Notes

  • Useful for validation before using RegExp methods.

References

Released under the MIT License.