[C/C++] string replace all 문자열 모두 치환
2015.12.11
std::string ReplaceAllSTL의 std::string를 이용하여 간단하게 문자열을 치환할 수 있다. 기본적으론 string.replace가 존재하며 해당 기능은 1번만 치환되므로 모든 문자를 치환하려면 추가로 작업을 해주어야 한다. 다음 코드를 보자 #include std::string replace_all( __in const std::string &message, __in const std::string &pattern, __in const std::string &replace ) { std::string result = message; std::string::size_type pos = 0; while ((pos = result.find(pattern)) != std::string:..