星期五, 八月 18, 2006

Quick remove or replace char in string

 

#include <string>

#include <algorithm>

std::string str="This is a test string, OK";

remove(str.begin(), str.end(),',');  //delete ',' in str

replace(str.begin(), str.end(),',','-'); //replace ',' with '-'

没有评论: