memgraph/include/utils/string/replace.hpp
2016-08-10 09:39:02 +01:00

23 lines
476 B
C++

#pragma once
#include <string>
namespace utils
{
// replaces all occurences of <match> in <src> with <replacement>
std::string replace(std::string src,
const std::string& match,
const std::string& replacement)
{
for(size_t pos = src.find(match);
pos != std::string::npos;
pos = src.find(match, pos + replacement.size()))
src.erase(pos, match.length()).insert(pos, replacement);
return src;
}
}