# Change node w/ regex oddity

**URL:** <https://discourse.nodered.org/t/change-node-w-regex-oddity/57168>\
**Category:** General\
**Created:** [24 January 2022 19:44 UTC](https://discourse.nodered.org/t/change-node-w-regex-oddity/57168 "2022-01-24T19:44:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hobbes1069](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hobbes1069/32/39892_2.png) [@hobbes1069](https://discourse.nodered.org/u/hobbes1069)\
**Post date:** [24 January 2022 19:44 UTC](https://discourse.nodered.org/t/change-node-w-regex-oddity/57168/1 "2022-01-24T19:44:42Z")

</div>

I'm prototyping using Node Red to publish device statistics (OS, Memory, CPU, etc) into a MQTT broker to later use the info for a dashboard. I had it working fine but now I'm trying to generalize it as much as possible to be portable to other devices.

Currently I'm setting the topic root using an inject node, but then need to append the specific OS node info to the end. For some reason whatever I specify is getting appended twice instead of once.

I'm passing the base topic in like this:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/6/96d703d49d88181607634d84259c843ee91134ba.png)

And then trying to append the node specific part of the topic here:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e3ce9ee600b76f1aaca6c9c9de3074ae56c45576.png)

With the result `snn/mem/device/rhel/os/os`

Is this a bug or a node red quirk?

Here's a partial of the flow. I haven't updated the other nodes yet until I get this working:

```auto
[{"id":"b10ff2498aaeb5f0","type":"OS","z":"8a41767628f10399","name":"","x":410,"y":40,"wires":[["f989c896d144302a"]]},{"id":"7af0f4f5f9b1996a","type":"inject","z":"8a41767628f10399","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":0.1,"topic":"snn/mem/device/rhel","x":140,"y":120,"wires":[["b10ff2498aaeb5f0","155b7c67b45de8cf","8f52460ef9fac9d2","927f702bae5530c8","1589319ae8f25a97"]]},{"id":"f989c896d144302a","type":"change","z":"8a41767628f10399","name":"OS Topic","rules":[{"t":"change","p":"topic","pt":"msg","from":"(.*)","fromt":"re","to":"$1/os","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":40,"wires":[["1b76fb93117376c6"]]},{"id":"1b76fb93117376c6","type":"debug","z":"8a41767628f10399","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","statusVal":"","statusType":"auto","x":880,"y":40,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [24 January 2022 20:06 UTC](https://discourse.nodered.org/t/change-node-w-regex-oddity/57168/2 "2022-01-24T20:06:38Z")

</div>

seems to be a bug in the change node regex to me.

This works `^(.*)$`

---

<div class="post-metadata">

**Author:** ![hobbes1069](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hobbes1069/32/39892_2.png) [@hobbes1069](https://discourse.nodered.org/u/hobbes1069)\
**Post date:** [24 January 2022 20:24 UTC](https://discourse.nodered.org/t/change-node-w-regex-oddity/57168/3 "2022-01-24T20:24:49Z")

</div>

Thanks for confirming. I'm on 2.1.5 and 2.1.6 is released. I'll try updating first just in case it's fixed.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 March 2022 20:25 UTC](https://discourse.nodered.org/t/change-node-w-regex-oddity/57168/4 "2022-03-25T20:25:25Z")

</div>

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