JavaScript test() Method: RegExp Object
Description
The test() method of the RegExp executes a search for a match between a regular expression and a specified string. Returns true or false.
Version
Implemented in JavaScript 1.2
Syntax
Regexp.test(str)
Parameter
RegExp: The name of the regular expression.
str: The string against which to match the regular expression.
Example:
The following web document demonstrates how the test() method can be used.
View the example in the browser
Supported Browser
Internet Explorer 7 | Firefox 3.6 | Google Chrome 7 | Safari 5.0.1 | Opera 10 |
Yes | Yes | Yes | Yes | Yes |
See also:
JavaScript Core objects, methods, properties.
Previous: JavaScript exec() Method: RegExp Object
Next:
JavaScript toSource() Method: RegExp Object
Test your Programming skills with w3resource's quiz.