ES6 - RegExp match()


Advertisements

This method retrieves the matches.

Syntax

str.match(regexp)           

Parameter Details

  • Regexp − A regular expression object.

Return Value

Returns an array of matches and null if no matches are found.

Example

var str = 'Welcome to ES6.We are learning ES6'; 
var re = new RegExp("We"); 
var found = str.match(re); 
console.log(found);  

Output

We     
es6_regexp.htm
Advertisements