Hi everyone! I'm the author of code.mu :)
I'd love to chat with my non-Russian audience. I'm looking for your feedback on the site and the translation quality. Let's chat:)
85 of 264 menu
◀ ▶

matchAll Method

matchAll method သည် regular expression နှင့် ကိုက်ညီသော အရာအားလုံးကို iterable object အဖြစ် ပြန်ပေးပြီး ၎င်း၏ element တစ်ခုစီသည် တွေ့ရှိခဲ့သည့် အရာ နှင့် ၎င်း၏ capturing groups များပါဝင်သော array ကို ပါဝင်ပါသည်။ Method ကို g modifier ဖြင့်သာ အသုံးပြုနိုင်ပါသည်။ ကိုက်ညီမှုမရှိပါက null ပြန်ပေးမည်။

Syntax

string.matchAll(regular expression);

ဥပမာ

ကိုက်ညီမှုအားလုံးကို ရယူပြီး loop ဖြင့် ထပ်ကျော့ကြည့်ကြပါစို့:

let str = '12 34 56'; let matches = str.matchAll(/(\d)(\d)/g); for (let match of matches) { console.log(match); }

Code ကို run လိုက်သော အခါ ရလဒ်:

[12, 1, 2] [34, 3, 4] [56, 5, 6]

ဥပမာ

Iterable object ကို ပုံမှန် array အဖြစ်သို့ ပြောင်းလဲကြည့်ကြပါစို့:

let str = '12 34 56'; let matches = str.matchAll(/(\d)(\d)/g); let res = Array.from(matches); console.log(res);

Code ကို run လိုက်သော အခါ ရလဒ်:

[ [12, 1, 2], [34, 3, 4], [56, 5, 6] ]

ဆက်လက်လေ့လာရန်

  • test method,
    သည် string ကို စစ်ဆေးပေးသည်
  • match method,
    သည် string ထဲတွင် ကိုက်ညီမှုကို ရှာဖွေပေးသည်
  • exec method,
    သည် အစဉ်လိုက် ရှာဖွေမှု ပြုလုပ်ပေးသည်
  • replace method,
    သည် ရှာဖွေခြင်း နှင့် အစားထိုးခြင်းကို ပြုလုပ်ပေးသည်
  • search method,
    သည် ရှာဖွေမှုကို ပြုလုပ်ပေးသည်
  • split method,
    သည် string ကို ပိုင်းခြားပေးသည်
← →
↑
မြန်မာ▼
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEnglishEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
ဝက်ဘ်ဆိုက် လုပ်ဆောင်ခြင်း၊ ဆန်းစစ်လေ့လာခြင်းနှင့် ပုဂ္ဂလိကပြုပြင်ခြင်းအတွက် ကျွန်ုပ်တို့သည် cookie များကို အသုံးပြုပါသည်။ ဒေတာများကို ပြုပြင်ခြင်းသည် ကိုယ်ရေးကိုယ်တာ မူဝါဒအတိုင်း ဖြစ်ပါသည်။
အားလုံးလက်ခံရန် ပြင်ဆင်ရန် ငြင်းပယ်ရန်