Extract number from a string

This might be stupid but what about just

if (bar == ON || boo == ON && (foo == ON))

wouldn’t it look to foo first in pars then look at the or

That could work. However, relying on these subtle side effects can be dangerous. I would still probably split it out as separate if statements.

i know its very old topic, but syntax should not change much for “replace”. I want to replace a very large String (content of one item), to format it better for the email notification.

the idae was, to replace ‘,’ with ‘< br>’ (html line break) to make the email notifiaction more beatiful. I tried to adapt the approach here, but as i have string as input, i’m not sure how to adapt properly.

Is there a syntax to parse String? this one didn’t work:

val itt = Double::parseDouble(item_to_tranform.replace(",", "<br>"))

and then

val mailActions = getActions("mail","mail:smtp:xxxxxxxxxx")
mailActions.sendHtmlMail("name@server.com", "[INFO] OpenHAB3", "<h1>OpenHAB3</h1>" + itt.state.toString() )

btw i’m working with OpenHAB3 on Synology Docker

That’s not a string.

What is that? You can’t go replacing bits of Item objects, if that is what it is.
Are you interested in some Item’s state?
Do you want to manipulate the string version of that Item’s state?

this item contains a very long/large String. actually a comma seperated list.

item_to_tranform

i want to replace the signs (comma) with the html line break,for the “state” of this item, to make it more readable.

completetly wrong track?

Okeydoke, that will be in the Item state then

That’s just string manipulation. No number parsing involved.

val itt = item_to_tranform.state.toString.replace(",", "<br>")
1 Like