File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -148,3 +148,20 @@ std::string escape(const std::string &s)
148
148
149
149
return result;
150
150
}
151
+
152
+ // / Copyright notice:
153
+ // / Attributed to Gauthier Boaglio
154
+ // / Source: https://stackoverflow.com/a/24315631/7501486
155
+ // / Used under MIT license
156
+ void replace_all (
157
+ std::string &str,
158
+ const std::string &from,
159
+ const std::string &to)
160
+ {
161
+ size_t start_pos = 0 ;
162
+ while ((start_pos = str.find (from, start_pos)) != std::string::npos)
163
+ {
164
+ str.replace (start_pos, from.length (), to);
165
+ start_pos += to.length ();
166
+ }
167
+ }
Original file line number Diff line number Diff line change @@ -67,4 +67,6 @@ Stream &join_strings(
67
67
// / programming language.
68
68
std::string escape (const std::string &);
69
69
70
+ void replace_all (std::string &, const std::string &, const std::string &);
71
+
70
72
#endif
You can’t perform that action at this time.
0 commit comments