使用这样的表:
article_tbl
ID varchar2(500)
REASON varchar2(500)
DESCRIPTION varchar2(500)
我需要从REASON
根据描述,日期位置可能会有所不同。
例如:
ID |DESCRIPTION | REASON |
------------------------------------------------------------------------------------------
1 |'DELETED' |'THIS MESSAGE HAS BEEN DELETED ON 25/05/2018. PLEASE CHECK IN ARCHIVE.' |
2 |'AUTOREPLY' |'THIS WAS AUTOREPLY ON 25/05/2018.' |
3 |'FORWARDED' |'THIS MESSAGE WAS FORWARDED ON 25/05/2015.MAILGROUP abc@outlook.com.' |
4 |'SENT' |'THIS MESSAGE WAS SENT TO SPECIFIC GROUP ON 25/05/2018' |
答案 0 :(得分:4)
如果我理解并且假设reason
的所有值都是您列出的格式之一,并且日期正确,则可以使用:
select regexp_substr(reason, '[0-9]{2}\/[0-9]{2}\/[0-9]{4}')
from article_tbl
这只是获取xx/xx/xxxx
格式的字符串,其中x
是一个数字;请注意,即使是99/45/8123
之类的内容也会被提取出来。