Switch Node & Change Node Reg Ex

775 views
Skip to first unread message

chris mobberley

unread,
Oct 7, 2014, 4:15:40 PM10/7/14
to node...@googlegroups.com
Hi All,

Would it be possible to get the change node to reflect the same set up for adding in regex matching as see in the switch node. I see in the change node code there seems to be a default /g whereas in the switch node you can just paste in the regex to match.

There also seems to be some ui inconsistencies between the two nodes. Regex in the switch node is a drop down item whereas the change node you have to tick a box to show you want to use regex.

Essentially it would be nice to paste in something like:

/([A-Z])\w+/gi

and not be constrained by other selections.

Nicholas O'Leary

unread,
Oct 7, 2014, 4:33:59 PM10/7/14
to node...@googlegroups.com
Hi Chris,

we had to add the checkbox as we couldn't reliably identify when the user wanted to user a regex and when it was a regular string. Rather than try to guess and get it wrong, the checkbox is there for the user to be clear. Given its a choice of either a string or a regex, a full drop-down isn't really necessary.

That said, on the todo list is an enhancement to the change node so that within the single node, multiple change rules can be set. That will simplify flows that want to set multiple properties on a message. When we come to that, we can rethink how it gets presented - a list of rules means a UI more like the Switch node.

We also need to update the Switch node to allow the user to specify regex flags. There's an open pull request for that here - https://github.com/node-red/node-red/pull/366 - but it needs some design work to get the UI right.

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.

chris mobberley

unread,
Oct 8, 2014, 3:46:16 AM10/8/14
to node...@googlegroups.com
Thanks for the reply Nick. I need to also do a bit more testing around how the change node is handling regex. If I use some regex within a function node and then use the same regex within a change node I'm seeing slightly different outputs with some space padding. I need to run some more tests tonight to be certain as I do have some other nodes within the flow which I need to check over too.
Reply all
Reply to author
Forward
0 new messages