Regex Invalid Regular Expression

I have a function I am writing to regex parse data between 2 strings. I am using a regex expression that I tested on Regex101

It seems to work well however I am getting an invalid expression error in the function when trying to use it.

image

I have tried /gm and that did not correct the error. The test flow is below for reference.

Thanks in advance

[{"id":"8bfde8da16407c5a","type":"inject","z":"4512ac95.5bc124","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"R1|0|meter 1.src=COD-#1.num=1#1.nam=MICPEAK#1.low=-150.0#1.hi=20.0#1.desc=Signal strength of MIC output in CODEC#1.unit=dBFS#1.fps=40#2.src=COD-#2.num=2#2.nam=MIC#2.low=-150.0#2.hi=20.0#2.desc=Average Signal strength of MIC ouput in CODEC#2.unit=dBFS#2.fps=20#3.src=TX-#3.num=5#3.nam=HWALC#3.low=-150.0#3.hi=20.0#3.desc=Voltage present at the Hardware ALC RCA Plug#3.unit=dBFS#3.fps=20#4.src=RAD#4.num=334#4.nam=+13.8A#4.low=10.5#4.hi=15.0#4.desc=Main radio input voltage at PA#4.unit=Volts#4.fps=0#5.src=RAD#5.num=0#5.nam=+13.8B#5.low=10.5#5.hi=15.0#5.desc=Main radio input voltage at CPU (continuous)#5.unit=Volts#5.fps=0#6.src=RAD#6.num=3#6.nam=MAINFAN#6.low=0.0#6.hi=8192.0#6.desc=Main radio fan RPM#6.unit=RPM#6.fps=0#7.src=TX-#7.num=1#7.nam=FWDPWR#7.low=0.0#7.hi=53.0#7.desc=RF Power Forward#7.unit=dBm#7.fps=20#8.src=TX-#8.num=2#8.nam=REFPWR#8.low=0.0#8.hi=53.0#8.desc=RF Power Reflected#8.unit=dBm#8.fps=20#9.src=TX-#9.num=3#9.nam=SWR#9.low=1.0#9.hi=999.0#9.desc=RF SWR#9.unit=SWR#9.fps=20#10...","payloadType":"str","x":630,"y":1080,"wires":[["76d5fa6773f47d21"]]},{"id":"76d5fa6773f47d21","type":"function","z":"4512ac95.5bc124","name":"","func":"var list = msg.payload.match(/(?<=R1\\|0\\|meter ).*$/);\nvar text = msg.payload;\n\n//let text = msg.payload.match(/(?<=R1\\|0\\|meter ).*$/);\n\nvar mtrlist= list.toString().split(\"#\");\nvar name  = mtrlist.toString().match(/(?s)(?<=nam=).*?(?=#)/);\n    \n msg = {payload: name};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":1000,"wires":[["a78ac82625852694"]]},{"id":"a78ac82625852694","type":"debug","z":"4512ac95.5bc124","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":900,"wires":[]}]

On Regex101, what 'Flavor' of regex have you got selected? If you change the Flavor to ECMAScript (JavaScript) then it highlights the error:

1 Like

I had
image
selected. I changed it to ECMAScript and yes it throws the error. I did not realized the flavor was that critical. That explains a lot.

Regards