REGEXP_LIKE排除字符串

时间:2013-11-26 07:09:49

标签: sql regex oracle

如何使用REGEXP_LIKE排除下面的字符串。

当'TEST'字符串的下一个字符是 - @

示例:

   TEST@TEST.COM
   XX@TEST-XX.COM
   TEST.TEST@LION.NL
   TEST@DSFFDS.BE
   NO.EMAIL@TEST.COM

但包括:

TESTTOM@LION.BE
HI@TESTP.COM

2 个答案:

答案 0 :(得分:1)

...
WHERE NOT REGEXP_LIKE(field,'TEST[-.@]')

答案 1 :(得分:1)

试试这个,

WITH t AS (
           SELECT 'TEST@TEST.COM' COL1
             FROM dual
            UNION   
           SELECT 'XX@TEST-XX.COM'
             FROM dual
            UNION  
           SELECT 'TEST.TEST@LION.NL'
             FROM dual
            UNION  
           SELECT 'TEST@DSFFDS.BE'
             FROM dual
            UNION  
           SELECT 'NO.EMAIL@TEST.COM'
             FROM dual
          )     
SELECT t.col1
  FROM t
WHERE NOT REGEXP_LIKE(COL1,'TEST[-.@]')
;