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:
parent
ae6c4223e2
commit
a28f68968c
1 changed files with 16 additions and 0 deletions
|
@ -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()
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in a new issue