oracle正規表示式regexp_like的使用

lihy114發表於2013-08-28
對某一個欄位進行to_number處理時,因為部分資料中包含字母,所以報錯 
ORA-01722: 無效數字

這樣就需要先除去字母以及字母后面的字元
--處理不含有字母的資料
update a_organ set code_new=code_old where regexp_instr(code_old,'[a-z]')=0;
--處理包含字母的資料
update a_organ set code_new=substr(code_old,1,regexp_instr(code_old,'[a-z]')-1)
where regexp_instr(code_old,'[a-z]')>0;

regexp_count()是統計字串中包含某個字串的個數
select regexp_count('111111','1') from dual;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28803801/viewspace-769438/,如需轉載,請註明出處,否則將追究法律責任。

相關文章