In place replace the 'search' substring by the 'replace' string in 'str'.
| 251 | |
| 252 | // In place replace the 'search' substring by the 'replace' string in 'str'. |
| 253 | inline bool ReplaceInPlace(std::string & subject, const std::string & search, const std::string & replace) |
| 254 | { |
| 255 | if (search.empty()) return false; |
| 256 | |
| 257 | bool changed = false; |
| 258 | |
| 259 | size_t pos = 0; |
| 260 | while ((pos = subject.find(search, pos)) != std::string::npos) |
| 261 | { |
| 262 | subject.replace(pos, search.length(), replace); |
| 263 | pos += replace.length(); |
| 264 | changed = true; |
| 265 | } |
| 266 | |
| 267 | return changed; |
| 268 | } |
| 269 | |
| 270 | // Replace the 'search' substring by the 'replace' string in 'str'. |
| 271 | inline std::string Replace(const std::string & subject, const std::string & search, const std::string & replace) |