Split String into different values

Hi all, I have a String [10] " 12345". I wanna split that string into 2 value: humid and temp
with humid = 123, temp = 45. What I have to do? Please help me! Tks.

If string is " 12345" with the space at front then in a function node would do the job..

msg.payload={humid:msg.payload.substr(1,3),temp:msg.payload.substr(4)};
return msg;

I don't know what does substr(1,3) & substr(4) mean? Could you explain it for me?

https://www.w3schools.com/jsref/jsref_substr.asp

Thank you so much! I've understood that.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.