refactor(strhelpers): extract shared strReplaceAll helper (#7711)
Co-authored-by: philmoz <philmoz@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
philmoz
Claude Sonnet 5
parent
2b9b8fd479
commit
8347285abe
@@ -1314,3 +1314,14 @@ int timezoneOffsetSeconds(int8_t tzHour, int8_t tzMinute)
|
||||
{
|
||||
return (tzHour * 3600) + (tzMinute * 15 * 60);
|
||||
}
|
||||
|
||||
void strReplaceAll(std::string &str, const std::string &from,
|
||||
const std::string &to)
|
||||
{
|
||||
if (from.empty()) return;
|
||||
size_t pos = 0;
|
||||
while ((pos = str.find(from, pos)) != std::string::npos) {
|
||||
str.replace(pos, from.length(), to);
|
||||
pos += to.length();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user