FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: obi am 11 März 2020, 18:58:41

Titel: HTTPMOD - ExtractAllRegex? (Werte aus mehrzeiliger Tabelle)
Beitrag von: obi am 11 März 2020, 18:58:41
Hallo,

ich stehe gerade auf dem Schlauch :) HTTPMOD ist sehr mächtig und ich weiß gerade nicht wie ich folgendes lösen kann. Ich habe eine Tabelle mit mehreren Zeilen welche immer gleich aufgebaut ist. Mit folgendem Regex bekomme ich die einzelnen Spalten, allerdings nur für die erste Zeile im Attribut "reading01Regex":
<tr><td colspan="1" rowspan="1">([a-zA-Z\-]+)<\/td><td class="center" colspan="1" rowspan="1">(\d+)<\/td><td class="center" colspan="1" rowspan="1">(\d+)<\/td><td colspan="1" rowspan="1"><\/td><\/tr>

Gibt es eine Möglichkeit wie bei ExtractAllJSON alle Regex Treffer als einzelne Readings anzulegen?

In der Wiki steht ja auch, dass man mehrere Capture Groups verwenden kann. Aber keine Infos wie man an alle Treffer kommt.
Regular Expressions with multiple capture Groups

The regular expressions used in the above example for a Poolmanager will take the value that matches one capture group. This is the part of the regular expression inside (). In the above example "([\d\.]+)" refers to numerical digits or points between double quotation marks. Only the string consiting of digits and points will match inside (). This piece is assigned to the reading.

You can also use regular expressions that have several capture groups which might be helpful when parsing tables. In this case an attribute like

reading02Regex something[ \t]+([\d\.]+)[ \t]+([\d\.]+)


Kann hier jemand Helfen?
Titel: Antw:HTTPMOD - ExtractAllRegex? (Werte aus mehrzeiliger Tabelle)
Beitrag von: amenomade am 11 März 2020, 19:54:39
Das gibt es meines Wissens nicht.
Aber wenn die Seite richtig gebaut ist, kannst Du vielleicht mit XPath arbeiten
Titel: Aw: HTTPMOD - ExtractAllRegex? (Werte aus mehrzeiliger Tabelle)
Beitrag von: VLPhoenix am 25 April 2024, 23:38:30
Das geht schon, wenn das zugehörige

attr myDevice reading[0-9]RegOpt s
gesetzt wird