I have a problem with my function that is trying to find an e-mail addresses. I have no idea what can be the problem :(
static int contains_mail(const unsigned char *buffer, int length, int detmode)
{
    const char *reg_exp = "([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z0-9._%+-]+)";
    regex_t regex;
    int reti;
    regmatch_t matches[2];
    int start0, end0, start1, end1;
    reti = regcomp(®ex, reg_exp, REG_EXTENDED);
    if(reti){ fprintf(stderr, "Could not compile regex\n"); exit(1); }
    reti = regexec(®ex, buffer, 2, matches, 0);
    start0 = matches[0].rm_so;
    end0 = matches[0].rm_eo;
    start1 = matches[1].rm_so;
    end1 = matches[1].rm_eo;
    printf("start0: %d", start0);
    printf("end0: %d", end0);
    printf("start1: %d", start1);
    printf("end1: %d", end1);
    if( !reti ){
        //printf("1");
        return 1;
    } else {
        //printf("0");
        return 0;
    }
}
Example input file:
dfo gpdf eriowepower riwope d@b.pl rwepoir weporsdfi dsfdfasdas@sdfaasdas.pl OSIDQOPWIEPOQWIE sdfs@asdsa.pl
WERO IWUEOIRU OWIERU WOIER asdas@asdasd.pl
aposidasop aposdi aspod iaspodi aspoid aspodi sdfsddfsd@asdasd.pl
werowerowe
It looks like it started with:
start0: 28end0: 28start1: 1end1: 8
but then it looks like it doesn't know that what is the end of the e-mail so I cannot calculate it :(
 
     
     
    