I need to implement a search mechanism for a list of words and give the result whether the word is found are not in a text provided.
I implemented this using boost
library. And it is as follows,
int main(int argc, char**argv)
{
int count = argc - 2;
std::string text = argv[1];
for(int i = 2; i < argc; i++)
{
boost::regex re(argv[i], boost::regex::icase);
if(boost::regex_search(text, re))
{
std::cout<<re<<" Found in "<<text<<std::endl;
count--;
}
else std::cout<<re<<" Not Found in " <<text<<std::endl;
}
if(count == 0)
{
std::cout <<"ALL WORDS ARE FOUND"<<std::endl;
}
else std::cout << "SOME WORDS ARE NOT FOUND"<<std::endl;
}
It is working fine for the command line arguements.
Now, what I need is I should provide an array of words directly to the boost search
method (if any is available) as a parameter which should return whether all words are found are not.
I've Googled for this but of no use.