| 443 | } |
| 444 | |
| 445 | void string_replace_all(std::string & s, const std::string & search, const std::string & replace) { |
| 446 | if (search.empty()) { |
| 447 | return; |
| 448 | } |
| 449 | std::string builder; |
| 450 | builder.reserve(s.length()); |
| 451 | size_t pos = 0; |
| 452 | size_t last_pos = 0; |
| 453 | while ((pos = s.find(search, last_pos)) != std::string::npos) { |
| 454 | builder.append(s, last_pos, pos - last_pos); |
| 455 | builder.append(replace); |
| 456 | last_pos = pos + search.length(); |
| 457 | } |
| 458 | builder.append(s, last_pos, std::string::npos); |
| 459 | s = std::move(builder); |
| 460 | } |
| 461 | |
| 462 | std::string regex_escape(const std::string & s) { |
| 463 | static const std::regex special_chars("[.^$|()*+?\\[\\]{}\\\\]"); |
no test coverage detected