const regex = /\bM[rs]\.\h(\p{Lu}\p{Ll}+(?:[\h-]\p{Lu}\p{Ll}+)*)\b/gmi;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\bM[rs]\\.\\h(\\p{Lu}\\p{Ll}+(?:[\\h-]\\p{Lu}\\p{Ll}+)*)\\b', 'gmi')
const str = `21. The SBSTA considered this agenda item at its 1^st^ meeting and resumed 3^rd^ meeting, on 15 November. It had before it document FCCC/SB/2016/3. At its 1^st^ meeting, the SBSTA agreed to consider this agenda item together with agenda item 11 of the SBI in informal consultations co-facilitated by Ms. Beth Lavender (Canada) and Mr. Alf Wills (South Africa). As referred to by the COP,[^18] the SBSTA also considered the issue of the review of the Warsaw International Mechanism for Loss and Damage associated with Climate Change Impacts, and agreed that it would be discussed at the same informal consultations. At its resumed 3^rd^ meeting, the SBSTA recommended two draft decisions on these matters for consideration and adoption at COP 22.[^19]. Mr. Seen and Mr. Conwell participate actively to the reconciliation.
Mr. Raúl Estrada-Oyuela (Argentina)
`;
// 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