CodesJava

Easy learning with example program codes

JavaScript RegEx exec()

The JavaScript RegExp exec() method is used to get an array containing all the matched groups for a specified string.

Syntax:

RegExpObject.exec(string) 

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

Return:
An array containing all the matched groups for a given string.

Example

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

Output

Returned value : HELLO
Please follow and like us:
error
Posted in Java   








Copyright © 2019 CodesJava DMCA.com Protection Status