Problems using Switch node with REGEX

1,125 views
Skip to first unread message

Mark Setrem

unread,
Sep 3, 2015, 9:35:09 AM9/3/15
to Node-RED
Ok I've been looking at this for an hour and can't see what I'm doing wrong.

I have a simple flow

[{"id":"f6878819.097878","type":"inject","name":"","topic":"","payload":"TEST","payloadType":"string","repeat":"","crontab":"","once":false,"x":131,"y":155,"z":"7f940735.806bf8","wires":[["6df38725.920c78"]]},{"id":"6df38725.920c78","type":"switch","name":"","property":"payload","rules":[{"t":"regex","v":"/.*TEST.*/i"},{"t":"else"}],"checkall":"false","outputs":2,"x":254,"y":156,"z":"7f940735.806bf8","wires":[["daf285b6.250d78"],["b476786b.4b8988"]]},{"id":"daf285b6.250d78","type":"debug","name":"Yes","active":true,"console":"false","complete":"payload","x":392,"y":97,"z":"7f940735.806bf8","wires":[]},{"id":"b476786b.4b8988","type":"debug","name":"No","active":true,"console":"false","complete":"payload","x":388,"y":204,"z":"7f940735.806bf8","wires":[]}]

which injects a payload "TEST"

a switch node that is set to:
1) "matches regex" "/.*test.*/i"
and 2)"otherwise"

and 2 debug nodes.

For the life of me I can't get the REGEX to trigger "true" , any ideas?


Nicholas O'Leary

unread,
Sep 3, 2015, 9:38:51 AM9/3/15
to Node-RED Mailing LIst
Hi Mark,

there's an outstanding issue with the regex option that you cannot specify the regex flags like 'i' in there. In fact, you shouldn't include the surrounding '/' either.

Needless to say, we need to improve that...

Nick





--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Setrem

unread,
Sep 3, 2015, 9:42:28 AM9/3/15
to Node-RED
Ta!

Back to using a function node then ;)

Reply all
Reply to author
Forward
0 new messages