Help getting a substring from payload

Sorry folks, seems I can't work out how to do this.

eg:
2024-10-21 17:45:18 UpLink Online

I want only the last part: UpLink Online

(Given UpLink and Online can change)

I have the string node, but I seem to be missing something how to get that done.

Or would it be better to use a function node and do some JS magic?

:person_shrugging:

EDIT:
This seems to work.

[{"id":"d04cbd8011adb764","type":"string","z":"0918ee609bf69fc7","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":":"}]},{"name":"delLeftMost","params":[{"type":"str","value":":"}]},{"name":"delLeftMost","params":[{"type":"str","value":" "}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":2890,"y":5530,"wires":[["35e4f569a22b2606"]]}]

If the length of the payload is always constant (at least the part which you don't want) I think this should work using Jsonata $substring in a change node,

[{"id":"deccf7af512c5094","type":"inject","z":"5a5b50a5e5a3beba","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2024-10-21 17:45:18 UpLink Online","payloadType":"str","x":600,"y":3200,"wires":[["ea3ff037815b9f80"]]},{"id":"ea3ff037815b9f80","type":"change","z":"5a5b50a5e5a3beba","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$substring(payload, 20, 20)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":3200,"wires":[["d88f5bdba063c609"]]},{"id":"d88f5bdba063c609","type":"debug","z":"5a5b50a5e5a3beba","name":"debug 2731","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1045,"y":3200,"wires":[]}]

How do you feel about regular expressions?

You could use a change node to remove the date and time portion.

Explanation: [0-9\-:] * matches any character which is a digit, hyphen or colon, followed by zero or more spaces. (It seems to work without the \ to escape any special meaning of the second hyphen too)

Your method will be easier to understand a year from now!

Edit: I like @smanjunath211 's solution too, only except that his debug node is named debug 2731 :scream:

Thanks both.

Yeah, in a few years time - who knows..... :wink:

So the string node hasn't got the stuff needed, huh?

I'll have to try to remember that too - for next time.

WRT the debug node... I'm not much better sometimes. :wink:

I may try what I did but keep these as options if it fails for unknown things I haven't thought of.

Not entirely my fault, inherited from forum during example downloads! but never bothered to clean up and renumber them :slight_smile:

We've all done it!
If we could search the forum for the very first debug 1000+ I hope it wouldn't turn out to be my fault!

Here is a flow that will renumber all the numbered debug nodes in a flows file. Configure the paths in the inject node, run the flow, replace the flows file with the one generated by the flow and restart node red. You do, of course, already have a backup of your flows file just in case.

[{"id":"2a1220f4e0f4ad64","type":"group","z":"bdd7be38.d3b55","name":"Rationalise debug node numbering","style":{"label":true},"nodes":["4cbc1bf30977dc4d","b6c70c743e51889d","8b2ca0887d7c0a3e","5b51b44a83135ec3","fefb82892cbc35d0","e60ea84d9655fc06","f6a6e6641bad366a"],"x":174,"y":3339,"w":972,"h":202},{"id":"4cbc1bf30977dc4d","type":"inject","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"Configure paths in here","props":[{"p":"flowfilePath","v":"/home/colinl/.node-red/flows.json","vt":"str"},{"p":"outPath","v":"/home/colinl/.node-red/flows.new.json","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":320,"y":3380,"wires":[["b6c70c743e51889d"]]},{"id":"b6c70c743e51889d","type":"file in","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"Read flow file","filename":"flowfilePath","filenameType":"msg","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":550,"y":3380,"wires":[["5b51b44a83135ec3"]]},{"id":"8b2ca0887d7c0a3e","type":"debug","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"debug 14","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":3500,"wires":[]},{"id":"5b51b44a83135ec3","type":"json","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"","property":"payload","action":"","pretty":false,"x":750,"y":3380,"wires":[["fefb82892cbc35d0"]]},{"id":"fefb82892cbc35d0","type":"function","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"Rationalise debug node names","func":"// msg.payload should include a flow file as an array of objects\nlet debugNumber = 1\nmsg.payload = msg.payload.map(rationalise) \nreturn msg;\n\nfunction rationalise(item) {\n    let answer = item\n    if (item.type === \"debug\") {\n        // check for name \"debug nnn\"\n        if (item.name.match(/debug [0-9]+$/)) {\n            //node.warn(`matching debug node found: ${JSON.stringify(item)}`)\n            // Change the name to an incrementing debug number\n            answer.name = `debug ${debugNumber++}`\n            //node.warn(`changed to: ${JSON.stringify(answer)}`)\n        }\n    }\n    return answer\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":3380,"wires":[["f6a6e6641bad366a"]]},{"id":"e60ea84d9655fc06","type":"file","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"Write flow file","filename":"outPath","filenameType":"msg","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":730,"y":3460,"wires":[["8b2ca0887d7c0a3e"]]},{"id":"f6a6e6641bad366a","type":"json","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"","property":"payload","action":"","pretty":true,"x":550,"y":3460,"wires":[["e60ea84d9655fc06"]]}]