1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Add replace_all()

This is just a function that will be used in the optimized tag-finding
function.
This commit is contained in:
Misa 2020-04-17 14:19:56 -07:00 committed by Ethan Lee
parent ae6c4223e2
commit a28f68968c

View file

@ -86,6 +86,22 @@ bool compare_nocase (std::string first, std::string second)
return false;
}
void replace_all(std::string& str, const std::string& from, const std::string& to)
{
if (from.empty())
{
return;
}
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos)
{
str.replace(start_pos, from.length(), to);
start_pos += to.length(); //In case `to` contains `from`, like replacing 'x' with 'yx'
}
}
void editorclass::getDirectoryData()
{