I have values like this:
AA B1 03 04C4 0186 30F2 28190908190909090908190819090908190908190819090819 55
And I need only the longest word in this “sentence”, so I tried Regular Expressions:
‘value_template: "{{value_json.RfReceived.Data | regex_findall_index(’\S{20,}‘)}}"’
But I get an error (HA does not understand the escaped S)
I tried the solution for this related problem in the template editor:
But HA says unknown error while parsing… even if I copy the suggested solution char by char
I then read the jinja docs but no other solution was obvious to me…
I copied your code and tested it. HA was complaining about some quotes. It looks like you are using some fancy quotes, because when I tested the same code with different quotes, it worked.
Works fine for me in the template editor, I actually tested it in the template editor.
If you add this to the template editor, does it not work:
{% set test = "AA B1 03 04C4 0186 30F2 28190908190909090908190819090908190908190819090819 55" %}
value_template: "{{ test | regex_findall_index('\S{20,}') }}"
Instead of writing the fancy quotes, just highlight the code you want to format and then press on the </> button at the top, then you will have the code formatted correctly.