diff --git a/nodes/core/logic/15-change.html b/nodes/core/logic/15-change.html
index b3eae64b3..892641d08 100644
--- a/nodes/core/logic/15-change.html
+++ b/nodes/core/logic/15-change.html
@@ -1,5 +1,5 @@
diff --git a/nodes/core/logic/15-change.js b/nodes/core/logic/15-change.js
index 7324c31f8..f0ebee24c 100644
--- a/nodes/core/logic/15-change.js
+++ b/nodes/core/logic/15-change.js
@@ -1,5 +1,5 @@
/**
- * Copyright 2013 IBM Corp.
+ * Copyright 2013, 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,71 +19,99 @@ module.exports = function(RED) {
function ChangeNode(n) {
RED.nodes.createNode(this, n);
- this.action = n.action;
- this.property = n.property || "";
- this.from = n.from || "";
- this.to = n.to || "";
- this.reg = (n.reg === null || n.reg);
- if (this.reg === false) {
- this.from = this.from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+
+ this.rules = n.rules;
+
+ if (!this.rules) {
+ var rule = {
+ t:(n.action=="replace"?"set":n.action),
+ p:n.property||""
+ }
+
+ if (rule.t === "set") {
+ rule.to = n.to||"";
+ } else if (rule.t === "change") {
+ rule.from = n.from||"";
+ rule.to = n.to||"";
+ rule.re = (n.reg===null||n.reg);
+ }
+ this.rules = [rule];
}
+
+ this.actions = [];
+
var valid = true;
- if (this.action === "change") {
- try {
- this.re = new RegExp(this.from, "g");
- } catch (e) {
- valid = false;
- this.error("Invalid 'from' property: "+e.message);
+
+ for (var i=0;i