If you don't have a regex, perhaps something like this will cut it for you.
SQL> with t as ( select 'A12345' as str from dual
2 union all
3 select 'AB456' as str from dual
4 union all
5 select '1234' as str from dual
6 union all
7 select 'AA 45' as str from dual)
8 select str
9 , replace(translate(str, '0123456789'
10 , ' '), ' ', null) as AAA
11 , replace(translate(str, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
12 , ' '), ' ', null) as NNN
13 from t
14 /
STR AAA NNN
------ ------ ------
A12345 A 12345
AB456 AB 456
1234 1234
AA 45 AA 45
SQL>
The function translate()converts numbers (or letters) to spaces, then replace()turns spaces to NULL.
source
share