First things first: it’s REGEX, not regex. openHAB is case sensitive in almost every scope.
Another thing: you’ll have to use .* at the beginning and the end of each regular expression.
Don’t use ^ (beginning of line) and $ (end of line) in openHAB.
The regular expression always has to match the whole string.
You don’t need to set square brackets around a space.
Please be aware that you better also chose the first char after the last digit (maybe another space?).
Short test:
rule "regex test"
when
Time cron "5/10 * * * * ?"
then
var theString = "this is node_network_transmit_bytes_total{device=\"br-lan\"} 123478 Bytes"
var regex = ".*node_network_transmit_bytes_total\\{device=\\\"br-lan\\\"\\} *(\\d+).*"
logInfo("regex","Source: {} REGEX: {} Result: {}", theString, regex, transform("REGEX",regex,theString))
end
As I use variables, I have to double the escape symbol, but you can see the resulting strings in the log:
2023-10-20 10:04:35.533 [INFO ] [org.openhab.core.model.script.regex ] - Source: this is node_network_transmit_bytes_total{device="br-lan"} 123478 Bytes REGEX: .*node_network_transmit_bytes_total\{device=\"br-lan\"\} *(\d+).* Result: 123478