51 bool bCaseInsensitive)
53 std::string new_string(s);
54 size_t str1Len = (str1 !=
nullptr) ? strlen(str1) : 0;
57 if (!s.empty() && str1Len > 0 && str2 !=
nullptr)
59 bool bReplaced =
false;
61 const char* pStart = s.c_str();
62 const char* pEnd = pStart + s.length();
68 const char* pFound =
nullptr;
77 pFound = strstr(pStart, str1);
81 if (pFound !=
nullptr)
85 out.append(pStart, pFound - pStart);
89 pStart = pFound + str1Len;
96 if (pStart !=
nullptr)
141 const std::string& s,
144 bool bCaseInsensitive)
146 std::string str1(1, c1);
147 std::string str2(1, c2);
148 return (
Replace(s, str1.c_str(), str2.c_str(), bCaseInsensitive));
Declaration of the Replace() functions, for replacing characters and strings in a string.
Declaration of the strstri function, case-insensitive string search for narrow character strings.
The namespace containing all the "helper" functions in the C++ code.
std::string Replace(const std::string &s, const char *str1, const char *str2, bool bCaseInsensitive)
Replace all occurrences of narrow string str1 with narrow string str2 in s. If str2 is empty then all...
char * strstri(const char *s1, const char *s2)
Do case-insensitive search for string 2 (s2) in string 1 (s1). Similar to the C library's strstr().