Es6-regexp-prototype-match

提供:Dev Guides
2020年6月23日 (火) 08:04時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

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