Hi all, I'm going crazy with this one.
I already have a function setup and working using the .match in function node with zero issues (See Below:)
const channel_no_regex = /(?<=\()[A-Z][0-9][^)]*(?=\))/gm;
const channel_no = msg.payload.match(channel_no_regex);
const channel_name = msg.payload.match(/(?<=\W )[a-zA-Z 0-9]+(?=\()/gm)
const event_type = msg.payload.match(/(?<=TYPE: ).*(?=\n)/gm)
const event_time = msg.payload.match(/(?<=TIME: ).*(?=\n)/gm)
if(channel_no_regex != null){
msg.ch = channel_no;
msg.chname = channel_name; //CHANGE THIS TO '0' NORMALLY. 1 IS JUST FOR TESTING DUE TO NL
msg.event = event_type[0];
msg.time = event_time[0];
return [msg, null];
}else{
return [null,msg]
}
I'm trying to build another function using regex and keep getting the error “TypeError: msg.payload.match is not a function”
I've tried everything I can think of. Below is what I have currently. Nothing works.
//const regex = /(?<=").[^"]+(?=")/gm;
//const match = msg.payload.match(/(?<=").[^"]+(?=")/gm)
var words = msg.payload.match(":");
//msg.match = match;
msg.words = words;
return msg;
Nothing I try works and I'm going crazy trying to work out why. Any suggestions would be very welcome. Thank you!