RegExp.prototype.test

Returns a boolean value that indicates whether or not a pattern exists in a searched string.

Syntax

test(string)

Parameters

Return value

true if there is a match between the regular expression and the string, false otherwise.

Examples

/[a-z]/.test('abc')
true
/[0-9]/.test('abc')
false