const regex = /(?<=\|).+?(?=\|\W)/gms;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<=\\|).+?(?=\\|\\W)', 'gms')
const str = `{{Infobox အတ္ထုပ္ပတ္တိ
| အမည် =စိုးသူ
| ဓာတ်ပုံ =Soe Thu.jpg
| သက်တမ်း =
| မွေးသက္ကရာဇ် = [[နိုဝင်ဘာ]] ၃၀ ရက်
| အမည်ရင်း =စိုးသူလွင်
| မိဘအမည် =ဦးခင်မောင်လွင်+ဒေါ်ခင်သူဇာ
| မွေးဖွားရာဒေသ=
| နိုင်ငံသား =[[Image:Flag of Myanmar.png|25px]] မြန်မာ
| လူမျိုး =ဗမာ
| ကိုးကွယ်သည့်ဘာသာ =ဗုဒ္ဓဘာသာ
| ပညာအရည်အချင်း = M.B;B.S
| အလုပ်အကိုင် = ဆရာဝန် ရုပ်ရှင်သရုပ်ဆောင်၊ အဆိုတော်
| ကြင်ဖော် = ခင်မြမြဝတ်မှုန်ဆွေ
| သားသမီး =
| ထင်ပေါ်ကျော်ကြားမှု =အကယ်ဒမီရ မင်းသား
| ထင်ရှားသည့်လက်ရာများ=
| ရရှိခဲ့သည့်ဘွဲ့တံဆိပ်များ=မြန်မာ့ ရုပ်ရှင် ထူးချွန်ဆု
| ကွယ်လွန်ရက် =
| ကွယ်လွန်ရာဒေသ=
| လက်မှတ်=
| ကွန်ယက် =http://www.facebook.com/pages/Soe-Thu
}}`;
// 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