I get as input a line which specifies a sensor and its settings for several kind of thresholds or so that all are represented in the same format and appear after each other 3 times (and some other stuff after this which isn't the issue here). Using regex101 I wrote my pattern which looks something like this:
^([0-9]{2})\:([a-zA-Z0-9\.\s]{4})([\s]?[\s\-\+\.0-9]{0,6}[\s]{1}){3}([\°|\s][a-zA-Z]\s)([0-9\.\-\s]{6}\s)(E[\+\-]{1}[0-9]{1}\s)([0-9\.\-\+\s]{0,6}\s)([a-zA-Z0-9\s]{0,10})
As you see I want to match this 3rd group ([\s]?[\s\-\+\.0-9]{0,6}[\s]{1}){3}
exactly three times - because I know it will appear three times. However regex101 tells me this:
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
So apparently it is not impossible to capture each single event of the group's repetition but trying to wrap brackets around the whole term doesn't seem to solve it either. Also in this SO comment it was mentioned that
there's no way to create a dynamic number of capture groups
which rather contradicts what the suggestion on regex101 and seems reasonable given that my attempt to solve it by the suggested surrounding group didn't work.
However, just to be sure I'd like to ask for clarification on this nevertheless because somehow it would also seem unreasonable to me to not have something that lets you catpure a repeating group a dynamic number of times. I suppose there should be at least one way to do this instead of making something like this:
([\s]?[\s\-\+\.0-9]{0,6}[\s]{1})([\s]?[\s\-\+\.0-9]{0,6}[\s]{1})([\s]?[\s\-\+\.0-9]{0,6}[\s]{1})
instead of e.g. something like this (which I know apparently doesn't work, I'm referring to the length of both versions however):
(([\s]?[\s\-\+\.0-9]{0,6}[\s]{1}){3})