I’m trying to parse a value returned by https://www.meteoromania.ro/wp-json/meteoapi/v2/starea-vremii as follows: value_template: ‘{{ (value_json[“features”]|selectattr(“properties.nume”,“eq”,“POIANA STAMPEI”)|first)[“properties”][“presiunetext”] | regex_search(r’[\d.]+‘, index=0) }}’
If I leave the regex out of the value_template: ‘{{ (value_json[“features”]|selectattr(“properties.nume”,“eq”,“POIANA STAMPEI”)|first)[“properties”][“presiunetext”] }}’ it works fine so clearly I’m doing something wrong.
And your regex above contains single quotes, which breaks it. Change those to doubles.
Also, please format code correctly for the forum with the </> button. I would have posted a corrected version for you, but the unformatted code now contains invalid “smart” quotes and I’m too lazy to fix all of those.
It returns “True” instead of extracting the number from the initial string.
Without the final regex I get something similar to this: “910.5 mb, in crestere”. I’m trying to further parse this to extract only the number “910.5”.