package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?ms).*Aussen.*?<\/code>.*?([^<]*)`)
var str = `<html> <head><title>Modbus Mapping - Guntamatic</title>
<meta charset="iso-8859-1"><style>table { border-collapse:collapse; text-align: center; }table, td, th { border:1px solid black; padding: 2px; }th {vertical-align: top; }
</style></head><body><h1>Modbus Mapping</h1>
<table>
<thead> <tr><th>Id</th><th>Register</th><th>Adresse</th><th>Typ</th><th>Einheit</th><th>Größe<br>(Byte)</th><th>Name</th><th>aktueller Wert</th></tr> </thead> <tbody> <tbody> <tr><td>0</td><td>0x4001</td><td>0x4000</td><td>string</td><td> </td><td>4</td><td>Betrieb</td><td><code>0x41555300</code>AUS</tr> <tr><td>1</td><td>0x4003</td><td>0x4002</td><td>float</td><td>°C</td><td>4</td><td>Aussentemperatur</td><td><code>0x40f1d8e2</code>7.56</td></tr> <tr><td>3</td><td>0x4007</td><td>0x4006</td><td>float</td><td>°C</td><td>4</td><td>Kesseltemperatur</td><td><code>0x4253c0e5</code>52.94</td></tr> </tbody></table> <h2>Erweiterte Texte</h2><table> <thead> <tr><th>Id</th><th>Register</th><th>Adresse</th><th>Größe<br>(Byte)</th><th>Name</th><th>aktueller Wert</th></tr> </thead> </tbody></table></body></html>`
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/