I want to be able to use a wildcard in string::find and then fetch what was in that wildcard place.
For example:
if (string::npos !=input.find("How is * doing?")
{
cout<<"(the wildcard) is doing fine."<<endl;
}
And so if I ask, "How is Mom doing?", the output would be "Mom is doing fine."
What libraries would I use for this, or how would I write the code manually? If I should use AIML, can AIML execute .bat files?
Regarding your question on how to do it manually, i will give you an idea with this simple code, which solves the example which you gave in the question.
#include<iostream>
#include<string>
using namespace std;
int main()
{
string expr="How is * doing?";
string input="How is Mom doing?";
int wildcard_pos=expr.find("*");
if(wildcard_pos!=string::npos)
{
int foo=input.find(expr.substr(0,wildcard_pos)),bar=input.find(expr.substr(wildcard_pos+1));
if(foo!=string::npos && bar!=string::npos)
cout<<input.substr(wildcard_pos,bar-wildcard_pos)<<" is doing fine\n";
}
}
You can easily modify this idea to suit your needs. Else, follow the answer given by src
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With