const regex = /\d/gu;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\d', 'gu')
const str = `0: 0,Ù ,Û°,߀,०,০,੦,૦,à¦,௦,౦,೦,൦,à¹,à»,༠,á€,á‚,០,á ,᥆,á§,á,á®°,á±€,á±,ê˜ ,ê£,꤀,ê©,ï¼
1: 1,Ù¡,Û±,ß,१,à§§,à©§,à«§,à§,௧,à±§,à³§,൧,๑,໑,༡,á,á‚‘,១,á ‘,᥇,á§‘,á‘,á®±,á±,᱑,꘡,꣑,ê¤,ê©‘,1
2: 2,Ù¢,Û²,ß‚,२,২,੨,૨,à¨,௨,౨,೨,൨,๒,à»’,༢,á‚,á‚’,២,á ’,᥈,á§’,á’,᮲,᱂,á±’,꘢,꣒,꤂,ê©’,ï¼’
3: 3,Ù£,Û³,߃,३,à§©,à©©,à«©,à©,௩,౩,೩,൩,๓,໓,༣,áƒ,á‚“,៣,á “,᥉,á§“,á“,᮳,᱃,᱓,꘣,꣓,꤃,ê©“,3
4: 4,Ù¤,Û´,ß„,४,৪,੪,૪,àª,௪,౪,೪,൪,๔,à»”,༤,á„,á‚”,៤,á ”,᥊,á§”,á”,á®´,᱄,á±”,꘤,꣔,꤄,ê©”,ï¼”
5: 5,Ù¥,Ûµ,ß…,५,à§«,à©«,à««,à«,௫,౫,೫,൫,๕,໕,༥,á…,á‚•,៥,á •,᥋,á§•,á•,᮵,á±…,᱕,꘥,꣕,꤅,ê©•,5
6: 6,Ù¦,Û¶,߆,६,৬,੬,૬,à¬,௬,౬,೬,൬,๖,à»–,༦,á†,á‚–,៦,á –,᥌,á§–,á–,á®¶,᱆,á±–,꘦,꣖,꤆,ê©–,ï¼–
7: 7,Ù§,Û·,߇,à¥,à§,à©,à«,à,à¯,à±,à³,àµ,๗,à»—,༧,á‡,á‚—,៧,á —,á¥,á§—,á—,á®·,᱇,á±—,꘧,꣗,꤇,ê©—,ï¼—
8: 8,Ù¨,Û¸,߈,८,à§®,à©®,à«®,à®,௮,à±®,à³®,൮,๘,໘,༨,áˆ,႘,៨,á ˜,᥎,᧘,á˜,᮸,᱈,᱘,꘨,꣘,꤈,꩘,8
9: 9,Ù©,Û¹,߉,९,৯,੯,૯,à¯,௯,౯,೯,൯,๙,à»™,༩,á‰,á‚™,៩,á ™,á¥,á§™,á™,᮹,᱉,á±™,꘩,꣙,꤉,ê©™,ï¼™`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions