JavaScript String ကိုက်ညီမှု()
ဥပမာများ
string ကို အသုံးပြု၍ "ain" အတွက် ရှာဖွေမှု
let text = "The rain in SPAIN stays mainly in the plain";
text.match("ain");
ပုံမှန်အသုံးအနှုန်းကို အသုံးပြု၍ "ain" အတွက် ရှာဖွေမှု။
let text = "The rain in SPAIN stays mainly in the plain";
text.match(/ain/);
"ain" အတွက် ကမ္ဘာလုံးဆိုင်ရာ ရှာဖွေမှု-
let text = "The rain in SPAIN stays mainly in the plain";
text.match(/ain/g);
ကမ္ဘာလုံးဆိုင်ရာ၊ အသေးအဖွဲ့-အာရုံမခံသော ရှာဖွေမှု-
let text = "The rain in SPAIN stays mainly in the plain";
text.match(/ain/gi);
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်း သည် match()
ပုံမှန်ဖော်ပြချက်တစ်ခုနှင့် string တစ်ခုနှင့် ကိုက်ညီသည်**
နည်းလမ်း သည် match()
ကိုက်ညီမှုများနှင့်အတူ array တစ်ခုကို ပြန်ပေးသည်။
တူညီမှုမတွေ့ပါက နည်းလမ်း match()
သည် null ဖြစ်သွားသည် ။
မှတ်ချက်
** ရှာဖွေမှုတန်ဖိုးသည် စာကြောင်းတစ်ကြောင်းဖြစ်ပါက၊ ၎င်းကို ပုံမှန်ဖော်ပြချက်အဖြစ်သို့ ပြောင်းသည်။
ကိုလည်းကြည့်ပါ-
အထားအသို
string.match(match)
ကန့်သတ်ချက်များ
Parameter | Description |
match | Required. The search value. A regular expression (or a string that will be converted to a regular expression). |
တန်ဖိုးများ ပြန်ပေးသည်။
ရိုက်ပါ။ | ဖော်ပြချက် |
ခင်းကျင်း ခြင်း သို့မဟုတ် null | ကိုက်ညီမှုများပါရှိသော ခင်းကျင်းတစ်ခု။ null ကိုက်ညီမှုမရှိပါက၊ |
String match() နှင့် string search() အကြား ကွာခြားချက်
နည်းလမ်း သည် match()
ကိုက်ညီမှုတစ်ခုအား ပြန်ပေးသည်။
နည်းလမ်းသည် ပထမ search()
ပွဲ၏ အနေအထားကို ပြန်ပေးသည်။
ပုံမှန်ဖော်ပြမှုရှာဖွေရေးနည်းလမ်းများ
JavaScript တွင်၊ ပုံမှန် expression text search ကို မတူညီသောနည်းလမ်းများဖြင့် လုပ်ဆောင်နိုင်သည်။
ပုံမှန်အသုံးအနှုန်းအဖြစ် ပုံစံ တစ်ခု ဖြင့်၊ ဤအရာများသည် အသုံးအများဆုံးနည်းလမ်းများဖြစ်သည်-
ဥပမာ | ဖော်ပြချက် |
---|---|
text.match( ပုံစံ ) | String method သည် match() |
text.search( ပုံစံ ) | စာတန်းနည်းလမ်းရှာဖွေမှု() |
ပုံစံ .exec(စာသား) | RexExp နည်းလမ်း exec() |
ပုံစံ .test(စာသား) | RegExp နည်းလမ်းစမ်းသပ်မှု() |
Browser ပံ့ပိုးမှု
match()
ECMAScript1 (ES1) အင်္ဂါရပ်တစ်ခုဖြစ်သည်။
ES1 (JavaScript 1997) ကို ဘရောက်ဆာအားလုံးတွင် အပြည့်အဝ ပံ့ပိုးထားသည်။
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |