2012年8月29日 星期三

REGEXP切割字串


SQL> with test as 
  2  (select 'ABC,DEF,GHI,JKL,MNO' str from dual 
  3  ) 
  select regexp_substr (str, '[^,]+', 1, rownum) split 
  5    from test 
  connect by level <= length (regexp_replace (str, '[^,]+'))  + 1
  7  / 
SPLIT
---------------------------------------------------------------------
ABC
DEF
GHI
JKL
MNO




參考
http://nuijten.blogspot.tw/2009/07/splitting-comma-delimited-string-regexp.html

http://www.oradev.com/regular_expressions_sql_oracle.jsp

沒有留言:

張貼留言