CodesJava

Easy learning with example program codes

JavaScript RegEx test() method

The JavaScript RegExp test() method is used to search a match between a regular expression and a specified string.

Syntax:

RegExpObject.test(string); 

Parameters:
string: It represents the string to be searched.

Return:
It returns true if match between a regular expression and a specified string found otherwise return false.

Example

<!DOCTYPE html>
<html>
<body>
<script>
var string  = "HELLO WORLD";  
var a = new RegExp( "HELLO", "g" );  
var print = a.test(string);  
document.write("Returned value : " +  print);   
</script>
</body>
</html>

Output

Returned value : true
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status