const regex = /(?s)(?:<td[^<]*>|\G(?!^))(?:<[^<]+>)?(?!\s+)([^<]*)(?:<[^<]+>)?/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?s)(?:<td[^<]*>|\\G(?!^))(?:<[^<]+>)?(?!\\s+)([^<]*)(?:<[^<]+>)?', 'g')
const str = `<table class="fiche_table_caracter"><tbody>
<tr>
<td class="caracteristique"><strong>Design</strong></td>
<td>Classique (full tactile)</td>
</tr>
<tr>
<td class="caracteristique"><strong>Système d'exploitation (OS)</strong></td>
<td>iOS</td>
</tr>
<tr>
<td class="caracteristique"><strong>Ecran</strong></td>
<td>4,7'' (1334 x 750 pixels)<br />16 millions de couleurs</td>
</tr>
<tr>
<td class="caracteristique"><strong>Mémoire interne</strong></td>
<td>128 Go, 1 Go RAM</td>
</tr>
<tr>
<td class="caracteristique"><strong>Appareil photo</strong></td>
<td>8 mégapixels</td>
</tr>
</tbody>
</table>`;
// 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