Baseline Widely available
Symbol.matchAll
å
ç½®éç¨ï¼well-knownï¼ç¬¦å·æå®æ¹æ³è¿åä¸ä¸ªè¿ä»£å¨ï¼è¯¥è¿ä»£å¨æ ¹æ®åç¬¦ä¸²çææ£å表达å¼çå¹é
é¡¹ãæ¤å½æ°å¯ä»¥è¢« 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