24 std::string::size_type firstpos = str->find(needle);
26 if (firstpos != std::string::npos)
27 str->replace(firstpos, needle.size(), instead);
35 std::string::size_type firstpos = str->find(needle);
37 if (firstpos != std::string::npos)
38 str->replace(firstpos, needle.size(), instead);
46 std::string::size_type firstpos = str->find(needle);
48 if (firstpos != std::string::npos)
49 str->replace(firstpos, strlen(needle), instead);
55 std::string* str,
const char* needle,
const char* instead) {
57 std::string::size_type firstpos = str->find(needle);
59 if (firstpos != std::string::npos)
60 str->replace(firstpos, strlen(needle), instead);
67 std::string::size_type firstpos = str->find(needle);
69 if (firstpos != std::string::npos)
70 (*str)[firstpos] = instead;
83 std::string::size_type firstpos = newstr.find(needle);
85 if (firstpos != std::string::npos)
86 newstr.replace(firstpos, needle.size(), instead);
95 std::string::size_type firstpos = newstr.find(needle);
97 if (firstpos != std::string::npos)
98 newstr.replace(firstpos, needle.size(), instead);
107 std::string::size_type firstpos = newstr.find(needle);
109 if (firstpos != std::string::npos)
110 newstr.replace(firstpos, strlen(needle), instead);
116 const std::string& str,
const char* needle,
const char* instead) {
119 std::string::size_type firstpos = newstr.find(needle);
121 if (firstpos != std::string::npos)
122 newstr.replace(firstpos, strlen(needle), instead);
130 std::string::size_type firstpos = newstr.find(needle);
132 if (firstpos != std::string::npos)
133 newstr[firstpos] = instead;
144 std::string::size_type lastpos = 0, thispos;
146 while ((thispos = str->find(needle, lastpos)) != std::string::npos)
148 str->replace(thispos, needle.size(), instead);
149 lastpos = thispos + instead.size();
157 std::string::size_type lastpos = 0, thispos;
158 size_t instead_size = strlen(instead);
160 while ((thispos = str->find(needle, lastpos)) != std::string::npos)
162 str->replace(thispos, needle.size(), instead);
163 lastpos = thispos + instead_size;
171 std::string::size_type lastpos = 0, thispos;
172 size_t needle_size = strlen(needle);
174 while ((thispos = str->find(needle, lastpos)) != std::string::npos)
176 str->replace(thispos, needle_size, instead);
177 lastpos = thispos + instead.size();
183 std::string* str,
const char* needle,
const char* instead) {
185 std::string::size_type lastpos = 0, thispos;
186 size_t needle_size = strlen(needle);
187 size_t instead_size = strlen(instead);
189 while ((thispos = str->find(needle, lastpos)) != std::string::npos)
191 str->replace(thispos, needle_size, instead);
192 lastpos = thispos + instead_size;
199 std::string::size_type lastpos = 0, thispos;
201 while ((thispos = str->find(needle, lastpos)) != std::string::npos)
203 (*str)[thispos] = instead;
204 lastpos = thispos + 1;
217 std::string::size_type lastpos = 0, thispos;
219 while ((thispos = newstr.find(needle, lastpos)) != std::string::npos)
221 newstr.replace(thispos, needle.size(), instead);
222 lastpos = thispos + instead.size();
231 std::string::size_type lastpos = 0, thispos;
232 size_t instead_size = strlen(instead);
234 while ((thispos = newstr.find(needle, lastpos)) != std::string::npos)
236 newstr.replace(thispos, needle.size(), instead);
237 lastpos = thispos + instead_size;
246 std::string::size_type lastpos = 0, thispos;
247 size_t needle_size = strlen(needle);
249 while ((thispos = newstr.find(needle, lastpos)) != std::string::npos)
251 newstr.replace(thispos, needle_size, instead);
252 lastpos = thispos + instead.size();
258 const std::string& str,
const char* needle,
const char* instead) {
261 std::string::size_type lastpos = 0, thispos;
262 size_t needle_size = strlen(needle);
263 size_t instead_size = strlen(instead);
265 while ((thispos = newstr.find(needle, lastpos)) != std::string::npos)
267 newstr.replace(thispos, needle_size, instead);
268 lastpos = thispos + instead_size;
276 std::string::size_type lastpos = 0, thispos;
278 while ((thispos = newstr.find(needle, lastpos)) != std::string::npos)
280 newstr[thispos] = instead;
281 lastpos = thispos + 1;
std::string & replace_all(std::string *str, const std::string &needle, const std::string &instead)
Replace all occurrences of needle in str.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
std::string & replace_first(std::string *str, const std::string &needle, const std::string &instead)
Replace only the first occurrence of needle in str.