const regex = /^([a-z0-9_-]+)(\.[a-z0-9_-]+)?@([a-z0-9_-]+)\.([a-z0-9]{2,})$/gmi;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^([a-z0-9_-]+)(\\.[a-z0-9_-]+)?@([a-z0-9_-]+)\\.([a-z0-9]{2,})$', 'gmi')
const str = `<header class="noSelect">
<div id="HIAccueil" class="I-B">
<img class="pointer" src="IMG/BACKGROUND/HEADER/logoban.png" alt="Accueil" onclick="clickMenu(tousLesMenus, 2, tousLesMenus[0].nom, 1, 0, 0, 0, tousLesMenus[1].url);">
</div>
<div id="HIPC">
<div id="HIProfile" class="I-B">
<!-- vide pour img via js -->
</div>
<div id="HIConnect" class="I-B">
<img class="pointer" src="IMG/BACKGROUND/HEADER/connect_hover.gif" alt="Connect" onclick="clickMenu(tousLesMenus, 5, tousLesMenus[0].nom, 4, 1, 1, 0, tousLesMenus[4].url);">
</div>
</div>
</header>
Tralloc_Nivek-02.baza_R-d421@gmail45.com
Tralloc_Nivek-02@gmail45.com
Tralloc_Nivek-02.baza_R-d421gmail45.c
010/226679
010226679
010/22.66.79
010/22 66 79
0470040747
0470/040747
0470/040.747
0470/04.07.47
0470/04 07 47
0470/040 747
+0032470040747
0032470/040 747
+00320470040747`;
// 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