[Solved] Rules: Matching a repeated Pattern with Regex

I’m having a string of hex numbers like this:

0C 72 00 ED 4D

The numbers should be extracted and assigned to items.
My first approach works and looks like this:

sString = serialString.state.toString.trim
sRegex = "([0-9A-F]{2})\\s?([0-9A-F]{2})\\s?([0-9A-F]{2})\\s?([0-9A-F]{2})\\s?([0-9A-F]{2})\\s?"
pattern = Pattern::compile(sRegex)
matcher = pattern.matcher(sString)
matcher.find()
item1= Integer::parseInt(matcher.group(1), 16)
item2= Integer::parseInt(matcher.group(2), 16)
...

That’s not very nice and things will become difficult if the lenght of the hex string changes.
So I did some research to see how repeating pattern can be matched.
In Java something like this should work:

sString = serialString.state.toString.trim
sRegex = "([0-9A-F]{2})"
pattern = Pattern::compile(sRegex)
matcher = pattern.matcher(sString)
while( matcher.find() ) {
    logInfo("patternMatcher", matcher.groupCount() + " " + matcher.group() )
}

However, this doesn’t work here: Only the first group is found.
Modifiers that work well with a regex tester result in errors when used in a rule:
The /myRegex/g usually returns all matching groups of a string.

So my questions is how can I find all groups of the string in a rule?
Is there an elegant way like in Java?

After a lot of testing I’ve found this working solution:

sString = serialString.state.toString.trim
sRegex = "([0-9A-F]{2})"
pattern = Pattern::compile(sRegex)
matcher = pattern.matcher(sString)
while (matcher.find()) {
    matchCnt = matchCnt + 1
    switch matchCnt {
        case 1:  logInfo("--1--",  matchCnt + " " + matcher.group())
        case 2:  logInfo("--2--",  matchCnt + " " + matcher.group())
        ....
    }
}

This produces this ouput:

[INFO ] [org.openhab.model.script.--1--] - 1 0C
[INFO ] [org.openhab.model.script.--2--] - 2 72
...

My misconception was that matcher.groupCount() returns the number of the current match.
However, it returns the number of groups in the regular expression which in this example always returns 1.