Es6-regexp-prototype-match

提供:Dev Guides
移動先:案内検索

ES6-RegExp match()

このメソッドは一致を取得します。

構文

str.match(regexp)

パラメータの詳細

  • Regexp -正規表現オブジェクト。

戻り値

一致の配列を返し、一致が見つからない場合はnullを返します。

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

出力

We