// ⭐️ Unicode "alphabetic characters" between word boundaries constword= /\b\p{Alphabetic}+\b/gu; // \p is not supported in Firefox yet❗consttext=` This is a naïve test of the matchAll() method. 這裡中文字 ✏️ うわ、喧嘩してる!何かあったんですか?`; // ⭐️ Chinese and Japanese characters are NOT "alphabetic characters"❗// ⭐️ (iterable) iterator of all matches (words)constmatches=text.matchAll(word);// iterate using for-of loopfor(let match of matches) { console.log(`${(match.index +'').padStart(3,'0')}: '${match[0]}'`);// ╰──index──╯ ╰─word─╯}// output// --------------// 005: 'This'// 010: 'is'// 013: 'a'// 015: 'naïve'// 021: 'test'// 026: 'of'// 029: 'the'// 033: 'matchAll'// 044: 'method'