Baseline Widely available
Symbol.matchAll
ã¯éçãã¼ã¿ããããã£ã§ãã¦ã§ã«ãã¦ã³ã·ã³ãã«ã§ãã Symbol.matchAll
ã表ãã¾ããString.prototype.matchAll()
ã¡ã½ããã¯æåã®å¼æ°ã«å¯¾ãã¦ãæååã«å¯¾ããç¾å¨ã®ãªãã¸ã§ã¯ãã®ç
§åãè¡ãã¤ãã¬ã¼ã¿ã¼ãè¿ãã¡ã½ãããããã®ã·ã³ãã«ã§æ¢ãã¾ãã
詳ããã¯ãRegExp.prototype[Symbol.matchAll]()
ããã³ String.prototype.matchAll()
ãåç
§ãã¦ãã ããã
const re = /[0-9]+/g;
const str = "2016-01-02|2019-03-07";
const result = re[Symbol.matchAll](str);
console.log(Array.from(result, (x) => x[0]));
// Expected output: Array ["2016", "01", "02", "2019", "03", "07"]
å¤
ã¦ã§ã«ãã¦ã³ã·ã³ãã« Symbol.matchAll
ã§ãã
const str = "2016-01-02|2019-03-07";
const numbers = {
*[Symbol.matchAll](str) {
for (const n of str.matchAll(/[0-9]+/g)) yield n[0];
},
};
console.log(Array.from(str.matchAll(numbers)));
// ["2016", "01", "02", "2019", "03", "07"]
仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4