#include #include using namespace boost; int main() { char exp0[] = "=a-c="; char exp1[] = "[^a-c]"; char exp2[] = "=[a-c]="; char *exps[] = {exp0,exp1,exp2}; regex example0 ("=a-c="); //the regex of the example regex example1 ("=[a-c]="); //the regex of the example regex correct ("[^a-c]"); //the correct regex regex expressions[] = {example0,correct,example1}; char p0[] = "=a-c="; char p1[] = "d"; char p2[] = "a"; char p3[] = "=a="; char *phrases[] = {p0,p1,p2,p3}; unsigned int i,j; for(i=0 ; i<3 ; i++) { for(j=0 ; j<4 ; j++) { match_results what; regex_match(phrases[j],what,expressions[i]); if(what[0].matched) printf("%s matched %s\n",exps[i],what.str(0).c_str()); else printf("%s did not match %s\n",exps[i],phrases[j]); } } return 0; }