Created
January 7, 2019 03:26
-
-
Save hxhb/7df084d11256af4d4fcff740b4a4826c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string replace_substring(const std::string& file,const std::string& replace_src,const std::string& replace_target) | |
{ | |
std::string resault(""); | |
std::string::size_type begin_index=0; | |
std::string::size_type pos_index=file.find(replace_src,begin_index); | |
while(pos_index != std::string::npos) | |
{ | |
resault += std::string(file.begin()+begin_index,file.begin()+pos_index); | |
resault += replace_target; | |
begin_index = pos_index+replace_src.size(); | |
pos_index = file.find(replace_src,begin_index); | |
} | |
resault += std::string(file,begin_index,file.size()-1); | |
return resault; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment