new helper function Replace()

svn path=/trunk/; revision=17505
This commit is contained in:
Royce Mitchell III 2005-08-24 05:50:21 +00:00
parent db03491cdc
commit 47b458eed1
2 changed files with 21 additions and 0 deletions

View file

@ -23,6 +23,25 @@
using std::string;
using std::vector;
string
Replace ( const string& s, const string& find, const string& with )
{
string ret;
const char* p = s.c_str();
while ( p )
{
const char* p2 = strstr ( p, find.c_str() );
if ( !p2 )
break;
if ( p2 > p )
ret += string ( p, p2-p );
p = p2 + find.size();
}
if ( *p )
ret += *p;
return ret;
}
string
FixSeparator ( const string& s )
{

View file

@ -739,6 +739,8 @@ private:
std::string StripSymbol ( std::string symbol );
};
extern std::string
Replace ( const std::string& s, const std::string& find, const std::string& with );
extern std::string
FixSeparator ( const std::string& s );