mein programm sieht inzwischen so aus, spuckt aber immer nur aus, dass der ausdruck (str) nicht gematched werden konnte.
kennt regex.h keine wildcards?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <regex.h>
#define BUFSIZE 1000
#define NMATCH 100
int main(void) {
char buf[BUFSIZE];
char found[BUFSIZE];
regex_t regexp;
regmatch_t rx_match[NMATCH];
char *str = "[0-9]+";
if (regcomp(®exp, str, 0)!=0) {
return 1;
}
for(;;) {
printf("> "); fflush(stdout);
if ((fgets(buf, BUFSIZE, stdin))==0)
return 0;
if ((regexec(®exp, buf, NMATCH, rx_match, 0))==0) {
printf("Match!!!\n");
memset(found,'0',BUFSIZE*sizeof(char));
memcpy(found, &buf[rx_match[0].rm_so], &buf[rx_match[0].rm_so] - &buf[rx_match[0].rm_eo]);
printf("gefunden: %s\n",found);
}
else
printf("Input doesn't match.\n");
}
}
Thx, der Duke.