diff --git a/nodes/core/logic/15-change.html b/nodes/core/logic/15-change.html
index 4e56a1f2f..4d5f5aa5d 100644
--- a/nodes/core/logic/15-change.html
+++ b/nodes/core/logic/15-change.html
@@ -96,7 +96,7 @@
$("#node-from-row").hide();
$("#node-to-row").show();
$("#node-reg-row").hide();
- $("#node-tip").html("Tip: expects a new property name and either a fixed value OR the full name of another msg.property eg: msg.sentiment.score");
+ $("#node-tip").html("Tip: expects a new property name and either a fixed value OR the full name of another message property eg: msg.sentiment.score");
}
if (a === "delete") {
$("#node-input-todo").html("called");
@@ -114,7 +114,7 @@
$("#node-from-row").show();
$("#node-to-row").show();
$("#node-reg-row").show();
- $("#node-tip").html("Tip: If contains is a regex, you must escape any special characters. Likewise replace with can accept regex results. Only works on strings.");
+ $("#node-tip").html("Tip: only works on string properties. If regular expressions are used, the replace with field can contain capture results, eg $1.");
}
//if (a === "replace") {
// $("#node-input-todo").html("called");
diff --git a/nodes/core/logic/15-change.js b/nodes/core/logic/15-change.js
index 7c80a7863..f48367075 100644
--- a/nodes/core/logic/15-change.js
+++ b/nodes/core/logic/15-change.js
@@ -24,7 +24,9 @@ function ChangeNode(n) {
this.to = n.to || " ";
this.reg = (n.reg === null || n.reg);
var node = this;
-
+ if (node.reg === false) {
+ this.from = this.from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+ }
var makeNew = function( stem, path, value ) {
var lastPart = (arguments.length === 3) ? path.pop() : false;
for (var i = 0; i < path.length; i++) {
@@ -36,12 +38,8 @@ function ChangeNode(n) {
this.on('input', function (msg) {
if (node.action == "change") {
- var from = node.from;
- if (node.reg === false) {
- from = from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
- }
try {
- node.re = new RegExp(from, "g");
+ node.re = new RegExp(this.from, "g");
} catch (e) {
node.error(e.message);
}