K
Knight
Hi,
in the following program, compiled using gcc on Linux, and invoked
as
a.out '[a-z]*' '111'
I get '111' matches '[a-z]*'. What am I doing wrong?
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <regex.h>
int main (int argc, char *argv[])
{
regex_t preg;
char errtext[100];
int rc;
if (rc = regcomp(&preg, argv[1], REG_EXTENDED|REG_NOSUB)) {
regerror(rc, &preg, errtext, 100);
printf("%s\n", errtext);
} else if (rc = regexec(&preg, argv[2], 0, NULL, 0)) {
regerror(rc, &preg, errtext, 100);
printf("%s\n", errtext);
} else {
printf("'%s' matches '%s'\n", argv[2], argv[1]);
}
}
in the following program, compiled using gcc on Linux, and invoked
as
a.out '[a-z]*' '111'
I get '111' matches '[a-z]*'. What am I doing wrong?
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <regex.h>
int main (int argc, char *argv[])
{
regex_t preg;
char errtext[100];
int rc;
if (rc = regcomp(&preg, argv[1], REG_EXTENDED|REG_NOSUB)) {
regerror(rc, &preg, errtext, 100);
printf("%s\n", errtext);
} else if (rc = regexec(&preg, argv[2], 0, NULL, 0)) {
regerror(rc, &preg, errtext, 100);
printf("%s\n", errtext);
} else {
printf("'%s' matches '%s'\n", argv[2], argv[1]);
}
}