include/StringUtils.hxx
// replace all occurrences of a in s with b
replace all occurrences of a in s with b
replace all occurrences of a in s with b
inline std::string replace(const std::string &s, const std::string &a, const std::string &b)
{
	std::string result;
	std::string::size_type pos = 0;
	while (1)
	{
		std::string::size_type onset = s.find(a, pos);
		if (onset == std::string::npos)
		{
			result += s.substr(pos, s.size()-pos);
			break;
		}
		result += s.substr(pos, onset-pos);
		result += b;
		pos = onset + a.size();
	}
	return result;
}
inline std :: string replace ( const std :: string & s , const std :: string & a , const std :: string & b ) { std :: string result ; std :: string :: size_type pos = 0 ; while ( 1 ) { std :: string :: size_type onset = s . find ( a , pos ) ; if ( onset == std :: string :: npos ) { result += s . substr ( pos , s . size ( ) - pos ) ; break ; } result += s . substr ( pos , onset - pos ) ; result += b ; pos = onset + a . size ( ) ; } return result ; }
replace all occurrences of a in s with b
replace all occurrences of a in s with b