2024-05-31 22:59:00 -04:00
|
|
|
#ifndef RFL_INTERNAL_STRINGS_REPLACE_ALL_HPP_
|
|
|
|
#define RFL_INTERNAL_STRINGS_REPLACE_ALL_HPP_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace rfl {
|
2024-06-08 14:10:59 -04:00
|
|
|
namespace internal {
|
|
|
|
namespace strings {
|
2024-05-31 22:59:00 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
inline std::string replace_all(const std::string& _str,
|
|
|
|
const std::string& _from,
|
|
|
|
const std::string& _to) {
|
|
|
|
auto str = _str;
|
2024-05-31 22:59:00 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
size_t pos = 0;
|
|
|
|
while ((pos = str.find(_from, pos)) != std::string::npos) {
|
|
|
|
str.replace(pos, _from.length(), _to);
|
|
|
|
pos += _to.length();
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
2024-05-31 22:59:00 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
} // namespace strings
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace rfl
|
2024-05-31 22:59:00 -04:00
|
|
|
|
|
|
|
#endif
|