! @brief replace all occurrences of a substring by another string @param[in,out] s the string to manipulate; changed so that all occurrences of @a f are replaced with @a t @param[in] f the substring to replace with @a t @param[in] t the string to replace @a f @pre The search string @a f must not be empty. **This precondition is enforced with
| 10923 | @since version 2.0.0 |
| 10924 | */ |
| 10925 | static void replace_substring(std::string& s, const std::string& f, |
| 10926 | const std::string& t) |
| 10927 | { |
| 10928 | assert(not f.empty()); |
| 10929 | for (auto pos = s.find(f); // find first occurrence of f |
| 10930 | pos != std::string::npos; // make sure f was found |
| 10931 | s.replace(pos, f.size(), t), // replace with t, and |
| 10932 | pos = s.find(f, pos + t.size())) // find next occurrence of f |
| 10933 | {} |
| 10934 | } |
| 10935 | |
| 10936 | /// escape "~" to "~0" and "/" to "~1" |
| 10937 | static std::string escape(std::string s) |