Oekel
(David K.)
January 4, 2024, 4:57pm
1
Hi,
I guess I just need a smal hint.
Following Syntax is testes for ECMAScript on regex101.com
Testing in Blocky will not match:
pushButton = {'A': '55', 'B': '15', 'C': '45', 'D': '51', 'E': '54'};
data = data.replaceAll('0x\\d{3}(\\d{2})',pushButton[value]); //value='B'
console.warn(data.replaceAll('0x\\d{3}(\\d{2})',pushButton));
[WARN ] [cript.ui.transforrm_radiofrequenz433] - 0x154551
What might I do wrong?
Maybee becourse it is a BUG becauce only Stringt and no real REGEX is supported in Blockly?
rlkoshak
(Rich Koshak)
January 4, 2024, 5:26pm
2
It’s all JavaScript under the covers. If you want to use a regex, you need to create a regex and pass it to the first argument of replaceAll
. See String.prototype.replaceAll() - JavaScript | MDN
You’ll have to use an “inline script” block to do that.
If you pass a string as the first argument, it’s going to look for that literal string to replace, not execute it as a regex.
1 Like
Oekel
(David K.)
January 4, 2024, 6:28pm
3
I missed the ECMAScript /<regex/ stuff for it
Thanks for your support. I postet a simple working Script in a new Post:
Hi,
I simply wanted to show how I realized SwitchState Changes of “virtual” Points/Switches (no Channel links) for IR or RF Wallplugs which are integreted over any MQTT-(IR/RF)Bridge.
Maybee you can give me feedback if there is a smarter Solution or If I am on the correct way.
At least it is a Blockly example you can use as template for a lot of usecases.
The Virtual Switch:
has a custom namespace (placed over Main UI “Add Metadate”–>“Enter Custom Namespace” >rfsend<
value: C
config:
Bi…
1 Like