ccxvii / minilibs

Various small libraries.
141 stars 13 forks source link

Small example for regex #3

Closed tawmoto closed 5 years ago

tawmoto commented 5 years ago

Hello, can you make a small example for the regex please? I cannot seem to make this work...I am trying this and i expect that i is 1, am I missing something? thanks.

    const char *err = NULL;
    Reprog *rep = regcomp((const char*)"[a-z]13", REG_ICASE, &err);

    Resub sub;
    int x = regexec(rep, "d13", &sub, REG_NOTBOL);

LE: it seems to work with "^[a-z]13". I have read that your regex uses JS flavour, but in JS ommitting the "^" is perfectly fine

ccxvii commented 5 years ago

See the example at the bottom of the file: https://github.com/ccxvii/minilibs/blob/master/regexp.c#L1134

You mention an i but there is no such variable in your code. Do you mean x? The return value of regexec is 0 if there is a match; the same behavior as the POSIX regexec function.