Files
triton/lib/tools/find_and_replace.hpp

28 lines
489 B
C++
Raw Normal View History

#ifndef ISAAC_TOOLS_FIND_AND_REPLACE_HPP
#define ISAAC_TOOLS_FIND_AND_REPLACE_HPP
2014-08-30 18:02:17 -04:00
#include <string>
namespace isaac
2014-08-30 18:02:17 -04:00
{
namespace tools
{
int inline find_and_replace(std::string & source, std::string const & find, std::string const & replace)
{
int num=0;
size_t fLen = find.size();
size_t rLen = replace.size();
for (size_t pos=0; (pos=source.find(find, pos))!=std::string::npos; pos+=rLen)
{
num++;
source.replace(pos, fLen, replace);
}
return num;
}
}
}
#endif