Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool TextGame::FindKeyword(const string &keyword, bool oneWord)
- {
- auto in = Capitalize(GetInput());
- auto kw = Capitalize(keyword);
- size_t overlap = 0;
- auto start = false;
- auto end = false;
- if (in.size() < kw.size()) return false;
- //PrintDebug("INPUT: " + GetInput() + "\nKEYWORD: " + kw);
- auto i = in.find(kw);
- if (i!=-1)
- {
- if (oneWord)
- {
- while(i!=-1)
- {
- start = (i == 0 || in[i - 1] == ' ');
- end = (i == in.size() - kw.size() ||
- in[i + kw.size()] == ' ');
- if (start && end) return in.find(kw) != -1;
- in = in.substr(i+kw.size());
- i = in.find(kw);
- }
- }
- else
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement