Function: isRegExp()
isRegExp(
val
):val is RegExp
Type guard to check if a value is a RegExp instance.
Parameters
val
unknown
The value to check
Returns
val is RegExp
True if the value is a RegExp
Example
typescript
const value: unknown = /^test$/i
if (isRegExp(value)) {
// TypeScript knows value is a RegExp
console.log(value.test('TEST')) // true
}