CCF认证 201803-3URL映射(正则表达式的使用)

CCF认证 201803-3URL映射(正则表达式的使用)_第1张图片

#include
using namespace std;
int n,m;
vector >ve={{regex(""),"([0-9]+)"},
			       {regex(""),"([^/]+)"},
			       {regex(""),"(.+)"}};
vector >rules;
int main(){
    scanf("%d%d",&n,&m);
    string p,r;
    for(int i=1;i<=n;i++){
        cin>>p>>r;
	for(auto j:ve){
	    p=regex_replace(p,j.first,j.second);
	}
	    rules.push_back({regex(p),r});
	}
	string s;
	smatch result;
	for(int i=1;i<=m;i++){
	    cin>>s;
	    int id=0;
	    for(auto j:rules){
		if(regex_match(s,result,j.first)){
		    id=1;
		    cout</ year_archive
/articles/// month_archive
/articles//// article_detail
/static/ static_serve
/articles/2004/
/articles/1985/09/aloha/
/articles/hello/
/static/js/jquery.js
/articles/10/25/0aaa/
*/

 

你可能感兴趣的:(CCF认证)