CodeSarang.Com
Home | 전체 메뉴 | 질문/답변 Join | Login | 검색   

 

string 의 문자열 치환 replace 구현

등록자 : cpueblo (유광희), 2008-12-24

string 의 문자열 치환 replace 구현

std string 의 문자열 치환 함수 입니다.

string __fastcall str_replace(const string &str, const string &pattern, const string &replace) { string result = str; string::size_type pos = 0; string::size_type offset = 0; while((pos = result.find(pattern, offset)) != string::npos) { result.replace(result.begin() + pos, result.begin() + pos + pattern.size(), replace); offset = pos + replace.size(); } return result; }

사용 예제

string newurl = str_replace (url, "\\", "/");

댓글 달기 (로그인이 필요합니다)
제목
내용

http://codesarang.com. mail to cpueblocpueblo.com