http://www.cnblogs.com/light169/archive/2006/10/18/532347.html
1.两个特殊的符号'^'和'$'。他们的作用是分别指出一个字符串的开始和结束
2.'*','+'和'?'相当于"{0,}","{1,}"和"{0,1}"。用大括号括起,用以表示重复次数的范围
3.还有一个'¦',表示“或”操作
4.'.'可以替代任何字符
5.方括号表示某些字符允许在一个字符串中的某一特定位置出现
"[ab]":表示一个字符串有一个"a"或"b"(相当于"a¦b");
"[a-d]":表示一个字符串包含小写的'a'到'd'中的一个(相当于"a¦b¦c¦d"或者"[abcd]")
6.方括号里用'^'表示不希望出现的字符,'^'应在方括号里的第一位
"%[^a-zA-Z]%"表示两个百分号中不应该出现字母
http://blog.csdn.net/a117653909/article/details/6462300
匹配正则表达式编程
//b*de*c 和bfddsdessscc 匹配,采用递归处理,分两段b*d和bfddsd 以及e*c和essscc int isMatch (const char *s, const char *p) { if ( !s && !p )//同时为空,返回真 { return 1; } else if ( !s || !p ) { return 0; } while ( *s != '\0' && *p != '\0' ) { if ( (*s == *p)&&(*s!='*') ) { ++s; ++p; continue; } else if ( *p == '*' ) { /* escape all '*' */ while ( *p == '*' ) { ++p; } if ( *p == '\0' ) //ab和a*匹配 { return 1; } while ( *s != '\0' ) { if ( *s == *p && isMatch (s+1, p+1) )//a*b和 acccb匹配,此处递归分段匹配 { return 1; } ++s; } } else { return 0; } } while ( *p == '*' ) { ++p; } if ((*p == '\0') && (*s == '\0')) { return 1; } return 0; } int _tmain(int argc, _TCHAR* argv[]) { const char *str = "bfdsc"; const char *pattern = "b*d*c"; if ( isMatch (str, pattern) ) { fprintf (stdout, "match ok!/n"); } else { fprintf (stdout, "match failed!/n"); } return 0; }