| 924 | |
| 925 | |
| 926 | std::string replaceStr(std::string s, const std::string &from, const std::string &to) |
| 927 | { |
| 928 | std::string::size_type pos1 = 0; |
| 929 | while (pos1 < s.size()) { |
| 930 | pos1 = s.find(from, pos1); |
| 931 | if (pos1 == std::string::npos) |
| 932 | return s; |
| 933 | if (pos1 > 0 && (s[pos1-1] == '_' || std::isalnum(s[pos1-1]))) { |
| 934 | pos1++; |
| 935 | continue; |
| 936 | } |
| 937 | const std::string::size_type pos2 = pos1 + from.size(); |
| 938 | if (pos2 >= s.size()) |
| 939 | return s.substr(0,pos1) + to; |
| 940 | if (s[pos2] == '_' || std::isalnum(s[pos2])) { |
| 941 | pos1++; |
| 942 | continue; |
| 943 | } |
| 944 | s.replace(pos1, from.size(), to); |
| 945 | pos1 += to.size(); |
| 946 | } |
| 947 | return s; |
| 948 | } |
| 949 | |
| 950 | void substituteTemplateFormatStatic(std::string& templateFormat, bool eraseColors) |
| 951 | { |
no test coverage detected