blog/backend/include/utility.hpp

16 lines
No EOL
451 B
C++

#ifndef _HEADER_ETHERYOBLOG_UTILITY
#define _HEADER_ETHERYOBLOG_UTILITY
#include <string>
inline void str_replace(std::string& str, const std::string& from, const std::string& to) {
if(from.empty())
return;
size_t start_pos = 0;
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length();
}
}
#endif //_HEADER_ETHERYOBLOG_UTILITY