:匹配前面的子表达式零次或多次。要匹配 字符,请使用 *。

.:匹配除换行符 \n 之外的任何单字符。要匹配 . ,请使用 . 。

注意.*这种情况要特殊处理一下即可。

int main()
{
    std::ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        string a,b;
        cin>>a>>b;
        b=regex_replace(b,regex("\\.\\*"),"(.)\\1*");
        if(regex_match(a,regex(b)))cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!

搜索专题 Previous
nbuoj 2704 贪心吃法 Next