c - POSIX regex not compiling -
I have this code to match the IP address pattern. But it does not seem to work and I do not know why it always prints "no matches" at the terminal
regex_t regex; Int rate; Four messagebuffs [100]; Reti = regcomp (and regex, "^ ([0- 9] {1,3}). ([0- 9] {1,3}). ([0- 9] {1,3}). ([ 0- 9] {1,3}) $ ", 0); If (reti) {FPintiff (stadder, "Reggae could not be compiled \ n"); Exit (1); } Reti = regexec (and regex, "124.168.21.3", 0, zero, 0); If (! Reti) {puts ("match"); } And if (reti == REG_NOMATCH) {puts ("no match"); } {Terror (reti, and regex, msgbuf, sizeof (msgbuf)); Fprintf (stderr, "Reggae match failed:% s \ n", msgbuf); Exit (1); } Regfree (& amp; regex); Any ideas?
I found, in fact I should specify the seam of the function field REG_EXTENDED and not 0.
Comments
Post a Comment