Splite value sensor obtained by scraper

Hello,

I have managed to obtain the arrival times of the bus from the company website through the scraper sensor but the information shown appears to me like this:

L9215 minutes

The problem is that the bus line (L92) appears attached to the minutes (15).

Can someone tell me how I can divide the information so that it appears more readable with some template?

regards

You can play with it in DevTools/Templates.

{% set text = 'L9215 minutes' %}
{{ text.split(' ')[0][:3] }} {{ text.split(' ')[0][-2:] }} {{ text.split(' ')[1] }}

Shows: L92 15 minutes

Hello

Thank you very much for the answer, the truth is that I do not know anything about jinja2 and I do not know their methods and functions as well as the parameters that are passed to them.

Thanks to your answer I managed to separate it, but I have a problem and it is that when the minutes are lower than 10, it divides badly, example

L9215 minutes β†’ divide it well and leave it in L92 15 minutes

L922 minutes β†’ it divides badly and leaves it in L92 22 minutes when it should put L92 2 minutes

Sorry, my bad.

{{ text.split(' ')[0][:3] }} {{ text.split(' ')[0][3:] }} {{ text.split(' ')[1] }}

should work, assuming the bus line has always three characters.

Hello,

Thank you very much again, now everything is working correctly.

If it’s not too much trouble, can you explain how this works?

[0] [: 3]
[0] [3:]

regards