Need help with RegEx Transform

Hey all,

I want to extract the current vaccine numers from the German RKI Website:

=> Content: "Gesamtzahl der Impfungen bis einschl. 28.12.2020: 41.962 " < I want to extract 41.962

The plan is to update this via Cronjob everyday at 9am (currently set to once a minute for testing):

rule "Impfzahlen Update"
when Time cron "0 0/1 * * * ? *"

then
    val String url = "https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquoten-Tab.html"

    val content = sendHttpGetRequest(url);

    val detailed_info = transform("REGEX","/[0-9]{1,}(\\.[0-9]{3})\\s\\s/",content);

    //Impfstatus.postUpdate(detailed_info);
    logInfo("Impf Update", "Status" + detailed_info);

end

The online Regex tester at https://regex101.com/ provides a “Full Match” for my RegEx: [0-9]{1,}(.[0-9]{3})\s\s

But from my rule I only get:

[INFO ] [e.smarthome.model.script.Impf Update] - Statusnull

Anyone got an Idea what I need to change? (For sure, RegEx Transformation is installed)
Thanks a lot in advance

Try this:

/.*[0-9]{1,}(\\.[0-9]{3})\\s\\s.*/

Unfortunately this also results in “null”. But thanks for your help

I meanwhile used the “code generator” for Java of https://regex101.com/ resulting in a working solution:


import java.util.regex.Matcher;
import java.util.regex.Pattern;

rule "Impfzahlen Update"
when Time cron "0 0/1 * * * ? *"

then

    val String regex = "[0-9]{1,}(.[0-9]{3})\\s\\s";

    val String url = "https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquoten-Tab.html"

    val String content = sendHttpGetRequest(url, 10000);

    val Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
    val Matcher matcher = pattern.matcher(content);
    while (matcher.find()) {
        Impfungen.sendCommand(matcher.group(0).replace('.',''));
    }
end