CodesJava

Easy learning with example program codes

Symbol.match JavaScript JS

The JavaScript Symbol.match property looks for the matching of a regular expression against a string.

Syntax:

Symbol.match

Parameters:
string: It represents the string.

Returns:
It returns true if regular expression matches against a string, otherwise returns true.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script>    
var alpha = /HELLO WORLD/;  
alpha[Symbol.match] = false;  
document.write('/HELLO WORLD/'.startsWith(alpha));  
</script>
</body>
</html>

Output:

true

Example 2:

<!DOCTYPE html>
<html>
<body>
<script>  
const regExp = /codesjava/;
 
regExp[Symbol.match] = false;
 
document.write('/codesjava/'.startsWith(regExp));
document.write("</br>");
 
document.write('/jai/'.endsWith(regExp));
 
</script>
</body>
</html>

Output:

true
false
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status