REGEXP_SUBSTR returns only one value. You can turn your row into a pseudo-table and then query it for matches. There is an XML based method that eludes me at the moment, but works using connections if you only have one source line:
SELECT REGEXP_SUBSTR(str, '[^ ]+', 1, LEVEL) AS substr FROM ( SELECT 'Txa233141b Ta233141 Ta233142 Ta233147 Ta233148' AS str FROM DUAL ) CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(str, '[^ ]+')) + 1;
... gives you:
SUBSTR -------------------- Txa233141b Ta233141 Ta233142 Ta233147 Ta233148
... and you can filter it out with a slightly simpler version of the original template:
SELECT substr FROM ( SELECT REGEXP_SUBSTR(str, '[^ ]+', 1, LEVEL) AS substr FROM ( SELECT 'Txa233141b Ta233141 Ta233142 Ta233147 Ta233148' AS str FROM DUAL ) CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(str, '[^ ]+')) + 1 ) WHERE REGEXP_LIKE(substr, '^[A-Za-z]{2}[0-9]{5,}$'); SUBSTR -------------------- Ta233141 Ta233142 Ta233147 Ta233148
It is not very beautiful, but does not contain several values ββin one field.
Alex poole
source share