const regex = /\[div(?:\sid=["|'](.*?)["|'])?(?:\sclass=["|'](.*?)["|'])?\](.*?)\[\/div\]/gms;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\[div(?:\\sid=["|\'](.*?)["|\'])?(?:\\sclass=["|\'](.*?)["|\'])?\\](.*?)\\[\\\/div\\]', 'gms')
const str = `sdfsdfsd
adafadfalkjdafdfa
[div id="bla" class="ups"]some multiple line text[/div]
[div class="bla"]some multiple line text
more lines
[/div]
[div id="first"]
some text
[/div]
Ovo ne bi trebalo da fatga
[div id="bla"]
On the other hand, and in terms of severity, **DNS or NS takeovers** are less common but create the highest impact. An NS subdomain takeover is similar in principle to other types of subdomain takeovers. And due to the major role that NS records play in internet traffic, and the possibility of attackers chaining multiple attack vectors, an NS takeover can lead to severe implications for the target organization.
*For our new blog series [Blast Radius][4], security professionals, researchers and experts deep dive into different attacks and vulnerabilities, explore how they can impact the entire internet ecosystem, and examine what they mean for organizations of all sizes, across all industries. To talk about the growing danger of DNS takeovers, we are joined by Patrik Hudák.*
poop
[/div]
adfadfadfadfaf`;
// 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