MCPcopy Create free account
hub / github.com/KratosMultiphysics/Kratos / ReplaceAllSubstrings

Function ReplaceAllSubstrings

kratos/utilities/string_utilities.cpp:164–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162/***********************************************************************************/
163
164std::string ReplaceAllSubstrings(
165 const std::string& rInputString,
166 const std::string& rStringToBeReplaced,
167 const std::string& rStringToReplace
168 )
169{
170 std::string output_string(rInputString);
171 std::size_t start_pos = 0;
172 while((start_pos = output_string.find(rStringToBeReplaced, start_pos)) != std::string::npos) {
173 output_string.replace(start_pos, rStringToBeReplaced.length(), rStringToReplace);
174 start_pos += rStringToReplace.length(); // Handles case where 'to' is a substring of 'from'
175 }
176 return output_string;
177}
178
179/***********************************************************************************/
180/***********************************************************************************/

Callers 5

FunctionBodyMethod · 0.85
InitializeParserMethod · 0.85

Calls 2

lengthMethod · 0.80
findMethod · 0.45

Tested by 1