0
How do I detect certain words on one line
Kinda like a keyword system. I'm using getline(cin, x , '\n') and I'm kerfuffled. Say I wanted to detect 'cat' and 'dog'. So, if you typed "cat: Maine Coon dog: Pug", it would output Maine Coon and Pug. How would I do that?
3 Réponses
+ 1
Check out this as well. It's pretty common to parse strings with Regular Expressions, or regex:
http://www.cplusplus.com/reference/regex/
- 1
I've got an example in this code (getInput function near bottom of the code).
https://code.sololearn.com/cMMmkTfOxOoR/?ref=app
I used a state machine to know what I was processing, since I had a fixed pattern.