正则匹配
#include <iostream>
using namespace std;
bool check(const char* s, const char* p)
{
if(*p==0) return 0==*s;
if(*(p+1)!='+')
{
if(*p==*s || (*p=='.' && *s!=0))
{
return check(s+1,p+1);
}
return false;
}
else
{
while(*p==*s || (*p=='.' && *s!=0))
{
if(check(s,p+2))
{
return true;
}
s++;
}
return check(s,p+2);
}
}
int main()
{
const char* pattern = "a+.+b";
const char* str = "aaaab";
cout<<check(str,pattern)<<endl;
return 0;
}