QRegularExpression and named capture groups
-
I would like to see a method for retrieving the names of the capture groups as well as the text captured by them. I want to pass all the captured texts to a Lua table, both numbered and named. I'm not sure how to request a feature in Qt properly, so I hope this is an okay place to start.
-
You would ask in the Qt Bug tracker.
https://bugreports.qt-project.org/secure/Dashboard.jspaYou should search to see if someone else is already requesting this. If you can, provide a small, compilable program that demonstrates what you wish to achieve and why it cannot be achieved with the class as-is.
-
Couldn't you do this using QRegularExpressionMatch::capturedTexts()? There might be problems with named capture groups of course, but you can store them in list and supply them to regex, right?
"http://qt-project.org/doc/qt-5.0/qtcore/qregularexpressionmatch.html#capturedTexts":http://qt-project.org/doc/qt-5.0/qtcore/qregularexpressionmatch.html#capturedTexts -
[quote author="warjan" date="1357571186"]Couldn't you do this using QRegularExpressionMatch::capturedTexts()?[/quote]
-From my understanding he wants the pattern of the group, not the matched string.-
-so in a regex "test(\d+)test" he literally wants "\d+". Which will be tough if you don't want to reimplement a regex engine. (think "test(\d+(\w)?)*test" or worse stuff)-
I think I got that wrong. Disregard what I said. -
In the pattern "test(?<first>\d+)test" I want to know that "first" is the name of the capture group. QRegularExpression or QRegularExpressionMatch just need to provide a key/value map for capture groups instead of assuming they are numerically indexed or that you know the names of the groups in advance.
Thank you for the bug report advice. I will look into that now!
-
Hi,
please review :-) https://codereview.qt-project.org/#change,45265