isRegExp

Test if a value is a regular expression.

Usage

var isRegExp = require( '@stdlib/assert/is-regexp' );

isRegExp( value )

Tests if a value is a regular expression.

var bool = isRegExp( /.+/ );
// returns true

bool = isRegExp( {} );
// returns false

Examples

var isRegExp = require( '@stdlib/assert/is-regexp' );

var bool = isRegExp( /.+/ );
// returns true

bool = isRegExp( new RegExp( '.+' ) );
// returns true

bool = isRegExp( '/.+/' );
// returns false

bool = isRegExp( {} );
// returns false

bool = isRegExp( null );
// returns false
Did you find this page helpful?