MariaDB REGEXP with escaping backslash has strange behaviour

29 Views Asked by At

I use MariaDB 10.6.8 and found this strange behaviour when using backslash and escaping backslash.

SET @x := 'abc\\def';
SELECT @x;
-- abc\def

SELECT @x REGEXP '\d'        ; -- 1  why this gives no error?
SELECT @x REGEXP '\\d'       ; -- 0  \d is not supported in MariaDB but what does this means
SELECT @x REGEXP '\\\d'      ; -- 0  ?
SELECT @x REGEXP '\\\\d'     ; -- 1  this makes sense: \\d, first slash escapes second
SELECT @x REGEXP '\\\\\d'    ; -- 1  ? 
SELECT @x REGEXP '\\\\\\\d'  ; -- 0  ok
SELECT @x REGEXP '\\\\\\\\d' ; -- 0  ok

Any idea what happens?

0

There are 0 best solutions below