| 31 | } |
| 32 | |
| 33 | void str_replace(std::string& s, const std::string_view from, const std::string_view to) |
| 34 | { |
| 35 | std::string str; |
| 36 | size_t pos = 0; |
| 37 | size_t pf = 0; |
| 38 | while ((pf = s.find(from, pos)) < s.size()) { |
| 39 | str.append(s, pos, pf - pos); |
| 40 | str.append(to); |
| 41 | pos = pf + from.size(); |
| 42 | } |
| 43 | if (str.size()) { |
| 44 | str.append(s, pos); |
| 45 | s = str; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | void str_replace(std::wstring& s, const std::wstring_view from, const std::wstring_view to) |
| 50 | { |