I would like to differentiate lines with alphanumeric (plus "_" char) strings that DO contains "%" and the ones that DOESN'T contains "%".
I came up with the following exemple but obviously my regex are not correct...
select
col a,
case
when REGEXP_LIKE( col ,'^[[:alnum:]_%]+$' ) then 'like'
when REGEXP_LIKE( col ,'^[[:alnum:]_]+$' ) then 'word'
else null
end as b
from
(
select 'eTR%t_u' col from dual
union
select '%GYh%t1' col from dual
union
select '4_OPhfk' col from dual
union
select 'aaaaaaa' col from dual
);
--------------- ---------------
%GYh%t1 | like |
4_OPhfk | like |
aaaaaaa | like |
eTR%t_u | like |
This should output:
--------------- ---------------
%GYh%t1 | like |
4_OPhfk | word |
aaaaaaa | word |
eTR%t_u | like |
I also tried [[:alnum:]_[^%]]+ but this does not work
Could someone give some insight on the correct regexes to use?
Thanks