const regex = new RegExp('(opening soon)|(coming soon)|(under construction)', 'gmi')
const str = `abcd coming soon.
...
123 "414-898-7667"
under construction. Bill Gates. Some other text. MSFT, AAPL, AMZN. Coming soon.
Opening later. Or may be opening soon.
Are you sure? Opening soon?
I bet they are still under construction. The builder said that the truck is coming Soon.`;
// 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