更新时间:2023-02-26 20:39:40
关于您关于如何手动执行此操作的问题,我将通过这个简单的代码给您一个想法,它解决了您在问题中给出的示例.
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";
}
}
您可以轻松修改此想法以满足您的需求.否则,按照 src
You can easily modify this idea to suit your needs. Else, follow the answer given by src