How to split a Sensor State

Hi,

i want to get two values out of this media_title:

Robin Schulz - Sugar | RSH - Radio Schleswig-Holstein

value1: Robin Schulz
value2: Sugar

what is the correct string?
value1: {{ states.media_player.radio.attributes.media_title.split(’ - ‘)[0] }} ?
value2: {{ states.media_player.radio.attributes.media_title.split(’ - ')[1] }} ?

And how to delete the Radio-Station from the String?

Thank you very much.

They are both correct.
You can play with it in the Template Dev Tool.

{% set strtext = 'Robin Schulz - Sugar | RSH - Radio Schleswig-Holstein' %}
{{ strtext.split(' - ')[0] }} # Robin Schulz
{{ strtext.split(' - ')[1] }} # Sugar | RSH
{{ strtext.split(' - ')[1].split('|')[0] }} # Sugar

GREAT !

Thank you so much.