const regex = /YMS\-15|MSM\-10|YMS\-14|MAN\-07|MSN\-02|MSM\-07S|MA\-05|MSM\-07|MSM\-04F|MSM\-03|MS\-X16|MAN\-03|MS\-X10|MS\-14A|MS\-R09|MS\-06F|MS\-14|MS\-11|MS\-09R|MS\-09|MS\-07B|MS\-07|MS\-06S|MS\-06J|MS\-06|MSN\-X2|MS\-05B|MAX\-03|MS\-14S|MAN\-X3|MAN\-08|MA\-08|MA\-05H|MAN\-X8|MA\-04X|MSM\-04|MAM\-07|YMS\-07B/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('YMS\\-15|MSM\\-10|YMS\\-14|MAN\\-07|MSN\\-02|MSM\\-07S|MA\\-05|MSM\\-07|MSM\\-04F|MSM\\-03|MS\\-X16|MAN\\-03|MS\\-X10|MS\\-14A|MS\\-R09|MS\\-06F|MS\\-14|MS\\-11|MS\\-09R|MS\\-09|MS\\-07B|MS\\-07|MS\\-06S|MS\\-06J|MS\\-06|MSN\\-X2|MS\\-05B|MAX\\-03|MS\\-14S|MAN\\-X3|MAN\\-08|MA\\-08|MA\\-05H|MAN\\-X8|MA\\-04X|MSM\\-04|MAM\\-07|YMS\\-07B', 'gm')
const str = `YMS-07B`;
// 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