diff --git a/packages/node_modules/@node-red/nodes/core/function/10-switch.html b/packages/node_modules/@node-red/nodes/core/function/10-switch.html
index be4e48a9b..434b50de5 100644
--- a/packages/node_modules/@node-red/nodes/core/function/10-switch.html
+++ b/packages/node_modules/@node-red/nodes/core/function/10-switch.html
@@ -112,7 +112,6 @@
}
if (type === "regex") {
r.case = rule.find(".node-input-rule-case").prop("checked");
- r.match = rule.find(".node-input-rule-match").prop("checked");
}
}
return r;
@@ -236,7 +235,6 @@
var andLabel = this._("switch.and");
var caseLabel = this._("switch.ignorecase");
- var matchLabel = this._("switch.returnmatches");
$("#node-input-rule-container").css('min-height','150px').css('min-width','450px').editableList({
addItem: function(container,i,opt) {
@@ -303,7 +301,6 @@
var rowInputCell = $('
',{style:"flex-grow:1; margin-left: 5px;"}).appendTo(row);
-
var valueField = null;
var numValueField = null;
var expValueField = null;
@@ -317,8 +314,6 @@
var caseSensitive = $('',{id:"node-input-rule-case-"+i,class:"node-input-rule-case",type:"checkbox",style:"width:auto;vertical-align:top"}).appendTo(row2);
$('',{for:"node-input-rule-case-"+i,style:"margin-left: 3px;"}).text(caseLabel).appendTo(row2);
- var returnMatch = $('',{id:"node-input-rule-match-"+i,class:"node-input-rule-match",type:"checkbox",style:"width:auto;vertical-align:top"}).appendTo(row2);
- $('',{for:"node-input-rule-match-"+i,style:"margin-left: 3px;"}).text(matchLabel).appendTo(row2);
selectField.on("change", function() {
var fieldToFocus;
@@ -423,7 +418,6 @@
valueField.typedInput('value',rule.v);
}
caseSensitive.prop('checked',!!rule.case);
- returnMatch.prop('checked',!!rule.match);
selectField.change();
var currentOutputs = JSON.parse(outputCount.val()||"{}");
diff --git a/packages/node_modules/@node-red/nodes/core/function/10-switch.js b/packages/node_modules/@node-red/nodes/core/function/10-switch.js
index d6c919a81..0e45f5f11 100644
--- a/packages/node_modules/@node-red/nodes/core/function/10-switch.js
+++ b/packages/node_modules/@node-red/nodes/core/function/10-switch.js
@@ -30,10 +30,7 @@ module.exports = function(RED) {
'false': function(a) { return a === false; },
'null': function(a) { return (typeof a == "undefined" || a === null); },
'nnull': function(a) { return (typeof a != "undefined" && a !== null); },
- 'regex': function(a, b, c, d, e, f) {
- if (f) { return (a + "").matchAll(new RegExp(b,d?'ig':'g')); }
- else { return (a + "").match(new RegExp(b,d?'i':'')); }
- },
+ 'regex': function(a, b, c, d) { return (a + "").matchAll(new RegExp(b,d?'ig':'g')); },
'empty': function(a) {
if (typeof a === 'string' || Array.isArray(a) || Buffer.isBuffer(a)) {
return a.length === 0;
@@ -200,9 +197,9 @@ module.exports = function(RED) {
state.elseflag = true;
}
try {
- const r = operators[rule.t](property,v1,v2,rule.case,msg.parts,rule.match )
+ const r = operators[rule.t](property,v1,v2,rule.case,msg.parts)
if (r) {
- if (rule.match == true && rule.t === "regex") {
+ if (rule.t === "regex") {
msg.matches = [];
for (const match of r) {
const le = match.length
diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json
index f1eb37fbd..34462a4aa 100644
--- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json
+++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json
@@ -760,7 +760,6 @@
"checkall": "checking all rules",
"stopfirst": "stopping after first match",
"ignorecase": "ignore case",
- "returnmatches": "return msg.matches",
"rules": {
"btwn": "is between",
"cont": "contains",
diff --git a/test/nodes/core/function/10-switch_spec.js b/test/nodes/core/function/10-switch_spec.js
index acbe20e1b..fe7726dc3 100644
--- a/test/nodes/core/function/10-switch_spec.js
+++ b/test/nodes/core/function/10-switch_spec.js
@@ -469,14 +469,14 @@ describe('switch Node', function() {
customFlowSwitchTest(flow, true, "oneTWOthree", done);
});
- it('should match regex with return-matches flag set true', function(done) {
- var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{"t":"regex","v":"(b[aio]..)","vt":"str","match":true}],checkall:true,outputs:1,wires:[["helperNode1"]]},
+ it('should match regex and return matches', function(done) {
+ var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{"t":"regex","v":"(b[aio]..)","vt":"str"}],checkall:true,outputs:1,wires:[["helperNode1"]]},
{id:"helperNode1", type:"helper", wires:[]}];
customFlowMessageSwitchTest(flow, true, {payload:"foobishbashboshpoo",matches:[{"match":"bish","index":3,"groups":["bish"]},{"match":"bash","index":7,"groups":["bash"]},{"match":"bosh","index":11,"groups":["bosh"]}]}, done);
});
- it('should match regex with return-matches flag set true - 2', function(done) {
- var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{"t":"regex","v":"[b][iao]","vt":"str","match":true}],checkall:true,outputs:1,wires:[["helperNode1"]]},
+ it('should match regex and return matches - 2', function(done) {
+ var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{"t":"regex","v":"[b][iao]","vt":"str"}],checkall:true,outputs:1,wires:[["helperNode1"]]},
{id:"helperNode1", type:"helper", wires:[]}];
customFlowMessageSwitchTest(flow, true, {payload:"foobishbashboshpoo",matches:[{"match":"bi","index":3,"groups":[]},{"match":"ba","index":7,"groups":[]},{"match":"bo","index":11,"groups":[]}]}, done);
});