1const regex = /([a-z]*)ball/g;
2const str = "basketball football baseball";
3let result;
4while((result = regex.exec(str)) !== null) {
5 console.log(result[1]);
6 // => basket
7 // => foot
8 // => base
9}
10
1
2 var str = "The best things in life are free";
3var patt = new RegExp("e");
4
5 var res = patt.exec(str);