Sembra che, in Oracle 11, il *
e +
i modelli (senza nulla che li preceda) generano corrispondenze a larghezza zero. Quindi (*)
e (+)
stanno catturando i gruppi ()
contenente i modelli a larghezza zero *
o +
rispettivamente.
Tutte queste query restituiscono una riga:
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '*' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '(*)' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '^*' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '^(*)' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '*1' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '+' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '(+)' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '^+' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '^(+)' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '+1' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '^+1' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '+1$' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '^+1$' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '()' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '12', '1(*)2' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '12', '1(+)2' );
Queste query non restituiscono alcuna riga:
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '*2' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '^*$' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', '^+$' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '12', '11(*)2' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '12', '11(+)2' );
Inoltre, confrontando qualsiasi modello con NULL
o una stringa contro un NULL
pattern non restituirà alcuna riga:
SELECT * FROM DUAL WHERE REGEXP_LIKE( NULL, '*' );
SELECT * FROM DUAL WHERE REGEXP_LIKE( '1', NULL );
Usando REGEXP_SUBSTR
:
SELECT REGEXP_SUBSTR( '1', '+' ) FROM DUAL;
Emette una singola riga contenente NULL
.