mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 09:28:15 +03:00
Add replace_all()
This is just a function that will be used in the optimized tag-finding function.
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user