package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?s)(?:<td[^<]*>|\G(?!^))(?:<[^<]+>)?(?!\s+)([^<]*)(?:<[^<]+>)?`)
var 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>`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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 Golang, please visit: https://golang.org/pkg/regexp/