Split string into objects

#1

Hi,

I use a serialport Node to receive ascii messages from an rs232 power inverter.
Everything works fine and I got informations in one payload string:

00.00.0000 01:21:40   3 124.9  0.23    29 236.2  0.12    28  23

Now I want to seperate each value into one payload object. Like payload.voltage, payload.power etc

My js knowledge is limited and I absolutely have no idea how to split this string.

I appreciate your help,
Sebastian

#2

And you already entered "split" into the forum search and nothing came up...

1 Like
#3

Yes, i googled a lot. But the values are not separated by commas to tabs but spaces of Individual length.

#4

This should provide the answer

https://www.google.com/search?client=safari&rls=en&ei=s3FuXIKTMsyp1fAP7feGmAQ&q=how+to+split+a+string+with+multiple+spaces+in+javascript

#5

Awesome, I will give \s+/ a try
Thank you!