const regex = /\(\(\(?([^}]*?)\)\)\)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\(\\(\\(?([^}]*?)\\)\\)\\)', 'gm')
const str = `((Short Title (in Navigation & Breadcrumb))) Pflanzen & Samen
((Post-Text)) Hast du unser Osterschoggi-Sortiment schon probiert? ((Schleckmaul))
[Ceci est un ((non visible)) (test)]
[[Ceci est un ((non visible)) (test)]]
Ceci est un [[visible ((non visible))]] (test)
Ceci est un ((non visible [non visible])) (test)
((Headline))
((non visible))
Ceci doit être traduit
((Sternchentext))
*Mit Cashback Fr. 39.90, Rückvergütung (Überweisung) einlösbar unter canon.ch/summer, gültig von 15.2. bis 15.5.2021 ((maximal 140 Zeichen inkl. Leerzeichen))
Lieferung per Paketkurier (Direktlieferung (normal))
`;
// 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