PL/SQL REGEXP_LIKE testing string for allowed characters

Posted by Arino on Stack Overflow See other posts from Stack Overflow or by Arino
Published on 2012-06-27T08:16:32Z Indexed on 2012/06/27 9:16 UTC
Read the original article Hit count: 168

Filed under:
|
|

I need to verify that the provided string has only allowed characters using Oracle regular expressions (REGEXP_LIKE). Allowed chars are: abcdefghijklmnopqrstuvwxyz0123456789_-. Trying to execute

SELECT CASE 
         WHEN REGEXP_LIKE('abcdefghijklmnopqrstuvwxyz0123456789_-.'
                        , '^[a-z0-9_\-\.]+$') 
         THEN 'true' 
         ELSE 'false' 
END tmp 
FROM dual;

results in 'false'.

Any ideas on this?

© Stack Overflow or respective owner

Related posts about regex

Related posts about Oracle