Regex_replace : Python regex operations not working in template?

I’m trying to replace words from English to another language in templates.
when I use regex_replace without any regex operations, it works just fine.
but when I want to set a word boundary using \b behind a word that needs to be replaced, it won’t work anymore.
testing my operations in an Python regex tester returns the result I’m looking for, but not in HA.
any idea why this is? according to the documentation on templating, it should work with Python regex operations or am I missing something?

Please post exactly what you’ve tried. Thanks.

trying to replace following words from english to dutch in one and the same template:
(as a workaround because when using relative_time to calculate time left, it’s all in english)

minute to minuut
minutes to minuten
hour to uur
hours to uren
day to dag
days to dagen
month to maand
months to maanden

state: >
    {% set t = now() %}
    {{ states('sensor.soc_last_update') | as_datetime | as_local | relative_time 
    | regex_replace(find='minute\b', replace='minuut')
    | regex_replace(find='minutes\b', replace='minuten')
    | regex_replace(find='hour\b', replace='uur')
    | regex_replace(find='hours\b', replace='uren')
    | regex_replace(find='day\b', replace='dag')
    | regex_replace(find='days\b', replace='dagen')
    | regex_replace(find='month\b', replace='maand')
    | regex_replace(find='months\b', replace='maanden')
    }}

but from the moment I use (any) punctuation marks in the “find” part it does not work.

You have to escape the \. 'minute\\b'

of course, the one thing I didn’t try…
thank you Petro! :slight_smile: