Help with switch node expression

I have a property that is a string. I only want to let the message thorugh the switch node if the number after the second dash - is 1.

A string that would pass looks like this:

PP-12345-1

A string that would not pass looks like this:

PP-12345-2-4-1

If I select "contains" and put in -1 the it also matches every message that has 1 after the first dash, which is not what I want.

Can anyone help me with this?

edit I misread your issue.

Let me retry.

$split(msg.payload,"-")[2]
Using a jsonata expression, split the incoming payload, get the 2nd element (starting from 0), if equal to 1, pass message

Anyone else know? :slight_smile:

I gave you a solution ?

Yes you did, sorry. It works perfectly, thanks!

1 Like

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