Hi all,

I have a problem with a regular expression in c++. It should be very simple to do, but I don't find any helpful information on the web regarding the usage of the regex.h library. I don't understand why my pattern should be wrong. Maybe someone can explain me where I'm wrong.

I have to use the regex.h library becausing I am using it on an embedded system where I don't want to use some other library like boost.
Code:
#include "stdio.h"
#include "stdlib.h"
#include "regex.h"
#include <string>

using std::string;

int main() {
    string str = "ab:";
    // this doesn't work
    string pattern = "[0-9|a-f][0-9|a-f]:";
    // this doesn't work either
    //string pattern = "[0-9|a-f]{2}:";
    // this would work - but it's not the correct pattern
    //string pattern = "[0-9|a-f]*[0-9|a-f]*:";
    regex_t pattern_t;

    // I have also used this
    //     int ret = regcomp(&pattern_t, pattern.c_str(), 0);
    int ret = regcomp(&pattern_t, pattern.c_str(), REG_EXTENDED|REG_NOSUB);
    printf ("ret: %d\n", ret);
    ret = regexec(&pattern_t, pattern.c_str(), (size_t) 0, NULL, 0);
    printf ("ret: %d\n", ret);

    return 0;

    // correct output
    // ret: 0
    // ret: 0
}
I would be greateful for any help or hint.

pippo