A better regexp handling

This commit is contained in:
Martin Tůma 2020-12-22 22:30:05 +01:00
parent 60691060ea
commit 29d4008068

View File

@ -205,14 +205,14 @@ bool Style::Layer::Filter::match(const PBF::Feature &feature) const
QString Style::Layer::Template::value(int zoom, const PBF::Feature &feature) const QString Style::Layer::Template::value(int zoom, const PBF::Feature &feature) const
{ {
QRegularExpression rx("(\\{[^\\}]*\\})"); QRegularExpression rx("\\{[^\\}]*\\}");
QString text(_field.value(zoom)); QString text(_field.value(zoom));
QRegularExpressionMatchIterator it = rx.globalMatch(text); QRegularExpressionMatchIterator it = rx.globalMatch(text);
QStringList keys; QStringList keys;
while (it.hasNext()) { while (it.hasNext()) {
QRegularExpressionMatch match = it.next(); QRegularExpressionMatch match = it.next();
QString val = match.captured(1); QString val = match.captured(0);
keys.append(val.mid(1, val.size() - 2)); keys.append(val.mid(1, val.size() - 2));
} }
for (int i = 0; i < keys.size(); i++) { for (int i = 0; i < keys.size(); i++) {