RichardU
(Richard)
September 26, 2022, 4:10pm
1
I’m trying to parse an entity into various elements. I’ve got everything before the dot and everything after the dot like this:
{% set my_test_json = {
"x": 'timer.group_office_work_test',
} %}
{{ my_test_json.x.split('.')[0]}}
{{ my_test_json.x.split('.')[1]}}
That gives me the desired timer
and `group_office_work_test’
How would I isolate the word after the dot and before the first underscore: e.g. group
And how would I isolate everything after the first underscore: e.g. office_work_test
Thanks, Richard
I think this will get you want you want…
{{ my_test_json.x.split('.')[1].split('_')[0] }}
1 Like
123
(Taras)
September 26, 2022, 4:34pm
3
{% set my_test_json = {"x": 'timer.group_office_work_test'} %}
{% set y = my_test_json.x.split('.')[1].split('_', 1) %}
{{ y[0] }}
{{ y[1] }}
RichardU
(Richard)
September 26, 2022, 8:19pm
4
Is there a way to get office_work_test without defining a new variable?
I’m trying {{my_test_json.x.split('_', 1) }}
But that gives me ['timer.group', 'office_work_test']
Thanks, Richard
123
(Taras)
September 27, 2022, 1:49am
5
{{ my_test_json.x.split('.')[1].split('_', 1)[1] }}
1 Like
RichardU
(Richard)
September 27, 2022, 2:08am
6
Thanks! That actually answers a lot of questions about the split command for me.
Cheers, Richard
1 Like