const regex = /@@\s*((?:.(?!@@))*?\bone central source\b.*?)\s*@@/gs;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('@@\\s*((?:.(?!@@))*?\\bone central source\\b.*?)\\s*@@', 'gs')
const str = `@@Consumers can also monitor their accounts regularly by allowing them to keep their accounts safe. Around-the-clock access to banking information provides early detection of fraudulent activity, thereby acting as a guardrail against financial damage or loss.@@ Online Bill Payment one of the great advantages of online banking is online bill pay. Rather than having to write checks or fill out forms to pay bills with an email like example@example.com, once you set up your accounts at your online bank, all it takes is a simple click or even less, as you can usually automate your bill payments. With online bill pay, it’s easy to manage your accounts from one central source and to track payments into and out of your account.@@ In spite of their many advantages, there are some drawbacks to using online banks as well. Here are some of the downsides/drawback of working with an online bank @@
`;
// 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