Pick word out of a variable

I have a variable when set says - Yellow thunderstorm warning or something similar

Is it possible to set another variable with just the first word, in this case (Yellow)

Thanks

One approach would be to ‘split’ the string on spaces and then grab the first word.

myVar = "Yellow thunderstorm warning"
split(myVar, " ")[0]
1 Like

Thanks, works great…

1 Like

I’m after a little more Variable help

I have a variable when populated looks similar to this

xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx

I would like to be able to stack them, so when applied to my dashboard, I can scroll through them easier.

Xxxx
Xxxx
Xxxx
Xxxx
Xxxx
Xxxx
Xxxx

I thought of using your previous method, but there can be 50 - 60 values, is there a easier way to apply this to 1 Variable

Thanks

You can split the string and then rejoin it with a newline character (\r\n):

myString = "xxx1, xxx2, xxx3, xxx4, xxx5, xxx6, xxx7, xxx8, xxx9, xxx10"
items = split(myString, ", ")
join(items, "\r\n")

When displayed in a tile, the result would be:

xxx1
xxx2
xxx3
xxx4
xxx5
xxx6
xxx7
xxx8
xxx9
xxx10
1 Like