Reference address:
IBM manual http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp? Topic=%2frtref%2fregcomp.htm
Books http://book.douban.com/subject/3794240/
Csdn read http://blog.csdn.net/wwwljc/article/details/6159644
C ++ 11 regular http://www.cnblogs.com/yejianfei/archive/2012/10/07/2713715.html
Match several regular expressions (email, IPv4:
# Include <sys/types. h> # Include <RegEx. h> # Include <Stdio. h> Int Main ( Int Argc, Char * Argv []) {regex_t RegEx; Int Reti; Char Msgbuf [ 100 ]; Const Char * Reg_exp = " ^ \ W + ([-+.] \ W +) * @ \ W + ([-.] \ W + )*\\. \ W + ([-.] \ W +) * $ " ;
// IPv4'^ (25 [0-5] | 2 [0-4] [0-9] | 1 [0-9] [0-9] | [1-9] [0-9] | [0-9]) \\.) {3} (25 [0-5] | 2 [0-4] [0-9] | 1 [09] [0-9] | [1-9] [0 -9] | [0-9]) $'
/* Compile Regular Expression */ RETI = Regcomp (& RegEx, reg_exp, reg_extended ); If (RETI) {fprintf (stderr, " Cocould not compile RegEx \ n " ); Exit ( 1 );} /* Execute Regular Expression */ RETI = Regexec (& RegEx, " Wangkangluo1@136.com " , 0 , Null, 0 ); If (! RETI) {puts ( " Match " );} Else If (RETI = Reg_nomatch) {puts ( " No match " );} Else {Regerror (RETI, & RegEx, msgbuf, Sizeof (Msgbuf); fprintf (stderr, " RegEx match failed: % s \ n " , Msgbuf); exit ( 1 );} /* Free compiled regular expression if you want to use the regex_t again */ Regfree ( & RegEx ); Return 0 ;}
End