Home » JavaScript RegExp test() Method

JavaScript RegExp test() Method

by Online Tutorials Library

JavaScript RegExp.prototype.test() Method

The test() method of JavaScript executes a search for a match between a regular expression and a specified string. If the match is found, it will return true. Otherwise, it will return false.

Syntax

Parameters

string : The string to be searched.

Return value

It will return true if there is a match between the regular expression and the specified string. Otherwise, it will return false.

Example 1

Test it Now

Output:

Matching and Return value : true  

Example 2

Test it Now

Output:

Matching and Return value : false  

Example 3

Test it Now

Output:

Match String : false  Match String : true  
Next TopicJavaScript RegExp

You may also like