Help with Regex template sensor

Hi all,

I’m trying to use regex to pull out a value from an email retrieved using the IMAP integration, but using the example of the integration page just gives me an “index out of range” error when using the Template in the Dev Tools.

A portion of the email is as follows:

See how much electricity you are likely to use this week so you can stay on top of your energy use.

Based on your current usage and the weather forecast, we estimate your electricity use for the week ahead is likely to be

$12.90

See your daily forecast below

There are in-face a ton more gaps in this than what has been pasted in here, but this is jist.

Want I want to do is extract the 12.90 as a value for the sensor (without the $ symbol).

Hope someone can help with this.

Thanks!

Would something like this work?

{{ your_e-mail_text | regex_findall_index('\d+\.\d+') }}

There is also a regex tester here that might be of help

2 Likes

Is that value ever likely to be a negative number?

You are a gentleman and a scholer!

I did have a regex, but it just came back blank, but worked in the regex testers I was using.

No I don’t think so.