user1332821
user1332821

Reputation: 83

PL/SQL Reg Exp found digit in string

This line should just check the c1 string from test_data table and if there is no digit then whole c1 string is displayed in result1 column. I tried testing this part on is own and it don't seem to work.

Can anyone help ? The tables and columns are all created, just not providing the result I needed. Result seems to be random: some strings with digits are inserted and some are not.

SELECT case WHEN REGEXP_Instr(c1, '[:digit:]')=0 
            THEN c1
      end result1
FROM test_data;

Upvotes: 1

Views: 945

Answers (1)

Jon Heller
Jon Heller

Reputation: 36798

Use [[:digit:]] instead of [:digit:] POSIX character classes only work inside brackets.

SELECT
    case WHEN REGEXP_Instr(c1, '[[:digit:]]')=0 THEN c1 end result1
    ,c1
FROM
(
    select 'asdf' c1 from dual union all
    select '1234' c1 from dual union all
    select 'as1234df' c1 from dual
) test_data;

Upvotes: 6

Related Questions