General Utility Library for C++14
2.11
|
Replacing all occurrences of a string within another string.
Functions | |
GUL_EXPORT std::string | gul14::replace (string_view haystack, string_view needle, string_view hammer) |
Replace all occurrences of a string within another string, returning the result as a std::string. More... | |
GUL_EXPORT std::string & | gul14::replace_inplace (std::string &haystack, string_view needle, string_view hammer) |
Replace all occurrences of a string within another string in-place. More... | |
std::string gul14::replace | ( | string_view | haystack, |
string_view | needle, | ||
string_view | hammer | ||
) |
Replace all occurrences of a string within another string, returning the result as a std::string.
Specifically, replace all occurrences of needle within haystack by hammer.
haystack | The string in which search&replace should take place. |
needle | The string to be searched for. If this is an empty string, a copy of haystack is returned. |
hammer | The replacement string. |
std::string & gul14::replace_inplace | ( | std::string & | haystack, |
string_view | needle, | ||
string_view | hammer | ||
) |
Replace all occurrences of a string within another string in-place.
This function replaces all occurrences of needle within haystack by hammer and returns a reference to the modified haystack.
haystack | The string in which search&replace should take place. |
needle | The string to be searched for. If this is an empty string, haystack is not changed. |
hammer | The replacement string. |