Strip character from text string

I get some data from a sensor that looks like

2023

I assume the little arrow in the front of the text must be some kind of carriage return? I haven't figured out how to strip that from the payload. That character is always the first but the length of the payload varies
thanks

You can do in a function node

msg.payload = msg.payload.substring(1)
return msg;

This will return the string minus the first character.

sorry but the funky character still shows up when I use that in a function

To remove any whitespace before and after, in a function node use.

msg.payload = msg.payload.trim()
return msg;

Or in a chnage node and JSONata
use

$trim($$.payload)

And there is also the contrib string node.

EDIT by @Paul-Reed - correct typo

that's the ticket !!
thanks

If what you actually want is the number, then you can use
msg.payload = Number(msg.payload)

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