summaryrefslogtreecommitdiff
path: root/libs/pbd/strreplace.cc
blob: dd90baf3249e6e3b7ce71137b9994a0153c87b08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <pbd/replace_all.h>

int
replace_all (std::string& str,
	     std::string const& target,
	     std::string const& replacement) 
{
	std::string::size_type start = str.find (target, 0);
	int cnt = 0;

	while (start != std::string::npos) {
		str.replace (start, target.size(), replacement);
		start = str.find (target, start+replacement.size());
		++cnt;
	}

	return cnt;
}