aboutsummaryrefslogtreecommitdiff
path: root/include/StringUtils.hpp
blob: 6b237dd3ba816ef7c0f7a96a7600416a7736329d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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;
    }
}