From 1fc21c3b657cb70997cd1215636dd00356b20e7d Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Wed, 13 Mar 2019 00:34:52 +0100 Subject: Use std::basic_regex to strip down field path. --- vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'vsm') diff --git a/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp b/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp index 351c2d1da0d..9131b21ddc9 100644 --- a/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp +++ b/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include LOG_SETUP(".vsm.fieldsearchspec"); @@ -154,19 +154,19 @@ FieldSearchSpecMap::FieldSearchSpecMap() : FieldSearchSpecMap::~FieldSearchSpecMap() {} namespace { - const vespalib::string _G_empty(""); - const vespalib::string _G_value(".value"); - const vespalib::Regexp _G_map1("\\{[a-zA-Z0-9]+\\}"); - const vespalib::Regexp _G_map2("\\{\".*\"\\}"); - const vespalib::Regexp _G_array("\\[[0-9]+\\]"); + const std::string _G_empty(""); + const std::string _G_value(".value"); + const std::basic_regex _G_map1("\\{[a-zA-Z0-9]+\\}"); + const std::basic_regex _G_map2("\\{\".*\"\\}"); + const std::basic_regex _G_array("\\[[0-9]+\\]"); } vespalib::string FieldSearchSpecMap::stripNonFields(const vespalib::string & rawIndex) { if ((rawIndex.find('[') != vespalib::string::npos) || (rawIndex.find('{') != vespalib::string::npos)) { - std::string index = _G_map1.replace(rawIndex, _G_value); - index = _G_map2.replace(index, _G_value); - index = _G_array.replace(index, _G_empty); + std::string index = std::regex_replace(std::string(rawIndex), _G_map1, _G_value); + index = std::regex_replace(index, _G_map2, _G_value); + index = std::regex_replace(index, _G_array, _G_empty); return index; } return rawIndex; -- cgit v1.2.3