regexp_substr in Oracle and Mysql

I executed the same statement in MySQL and Oracle, but they returned different results. Regular expression “/?” means to return zero or more “/”, but why would MySQL return me a “products”, is the MySQL implementation wrong?

SELECT
  REGEXP_SUBSTR('http://www.example.com/products',
                'http://([[:alnum:]]+\.?){3,4}/?') "REGEXP_SUBSTR"
  FROM DUAL;

Oracle Output:
REGEXP_SUBSTR
http://www.example.com/

MySQL Output:
REGEXP_SUBSTR
http://www.example.com/products

I queried the documentation for Oracle and MySQL, and they were interested in “? The definition of ” is to match zero or one character.MySQL says they implemented regular support with ICU libraries.But the output of ICU is “http://www.example.com/”.

int main(int argc, char *argv[]) {
    uint32_t flags = 0;
    flags |= UREGEX_UNIX_LINES;
    flags |= UREGEX_CASE_INSENSITIVE;
    const char *c_source_char = "http://www.example.com/products";
    const char *c_pat_char = "http://([[:alnum:]]+\\.?){3}/?";;
    UErrorCode status = U_ZERO_ERROR;
    URegularExpression *regexp = uregex_openC(c_pat_char, 0, NULL, &status);
    UChar ustr[100];
    u_uastrcpy(ustr, c_source_char);
    uregex_setText(regexp, ustr, -1, &status);
    if (uregex_find(regexp, 0, &status)) {
        int32_t start = uregex_start(regexp, 0, &status);
        int32_t end = uregex_end(regexp, 0, &status);
        if(end - start > 0) {
            std::string res(c_source_char+start, c_source_char+end);
            std::cout << res << std::endl;
        }
        
        printf("Found match at %d-%d\n", start, end);
    }
    uregex_close(regexp);
    return 0;
}

Read more here: Source link