How do i censor specific words in a string?

#include <iostream>
#include <iterator>

int main()
{


std::string vect = "one two nyes four nyes five nyes six";
std::string ban = "nyes";
int match = 0;
for (size_t i=0;i<vect.size();i++){
for (size_t j=0;j<ban.size();j++){
if (vect[i+j]==ban[j]) {
match++;
}
if (match = ban.size()) {
for (size_t y=i;y<i+ban.size();y++) {
vect[y] = '*';
}
}
}
}
std::cout << vect;
}
I just started learning, and in an exercise that wants me to censor specific words in a string, this is what I came up with. I was able to compile and execute in VS, but the result was an error? https://www.upsers.biz/

/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libstdc++-v3/include/bits/bas
Possibly:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <iterator>
#include <string>

int main()
{
	std::string vect {"one two nyes four nyes five nyes six"};
	const std::string ban {"nyes"};

	for (size_t fnd {}, pos {}; (fnd = vect.find(ban, pos)) != std::string::npos; pos = fnd + 1)
		vect.replace(fnd, ban.size(), "*");

	std::cout << vect;
}



one two * four * five * six

1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <string>
#include <regex>

int main()
{
	std::string vect("one two nyes four nyes five nyes six");
	std::regex re("nyes");
    std::cout <<  std::regex_replace(vect, re, "*");
}

one two * four * five * six 
What exactly does 'specific words in a string' mean?

Can the word be a fragment (ie. part of another word)? For example, does 'placate' contain the word 'cat'?
Is the search for words case insensitive? For example, would 'The' match the word 'the'?
Hey Einsteins, it's a two-year-old account blatantly posting spam.
Topic archived. No new replies allowed.