diff options
Diffstat (limited to 'include/StringUtils.hpp')
-rw-r--r-- | include/StringUtils.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/StringUtils.hpp b/include/StringUtils.hpp new file mode 100644 index 0000000..6b237dd --- /dev/null +++ b/include/StringUtils.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include <string> + +namespace dchat +{ + static std::string stringReplaceChar(const std::string &str, const std::string &from, const std::string &to) + { + std::string result = str; + size_t pos = 0; + while((pos = result.find(from, pos)) != std::string::npos) + { + result.replace(pos, from.size(), to); + pos += to.size(); + } + return result; + } +} |