I am trying to parse strings of the form
{{name1 | filter1|filter2 |filter3}}
into (name1, filter1, filter2, filter3)
.
I have a RegEx:
static const regex r("\\{\\{\\s*([\\.\\w]+)(\\s*\\|\\s*[\\.\\w]+)*\\s*\\}\\}");
And I want to find all occurences of the second group, which marked with a Kleene star (...)*. The problem is that I can only find last occurrence of the group.
Instead I use the following RegEx:
static const regex r("\\{\\{\\s*([\\.\\w]+)((\\s*\\|\\s*[\\.\\w]+)*)\\s*\\}\\}");
To find the second capture group (whole substring " | filter1|filter2 |filter3"
) and parse it with another RegEx.
How can it be done in C++?
The most similar question is here: Regex: Repeated capturing groups