所以我有一个函数,它返回字符串的组合(多个值)。我需要提取后面跟有char“DL:“的所有内容。但仅限于此。
因此在提取之前:
**pck_import.GETdocnumber(XML_DATA)**
________________________________________
DL:2212200090001 Pr:8222046017
________________________________________
Obj:020220215541 DL:1099089729
________________________________________
DL:DST22017260
________________________________________
DL:22122000123964 Pr:8222062485
________________________________________
DL:22122000108599
________________________________________
Obj:0202200015539 DL:2100001688
在每种情况下,我都需要在char“DL:“后面加上“number”。“DL:“可以是单独的,可以是第一个位置(在多个值之间),也可以是最后一个字符串。而且在某些情况下,“DL:“值也包含char。
因此,输出:
**OUTPUT**
______________
2212200090001
______________
1099089729
______________
DST22017260
______________
22122000123964
______________
22122000108599
______________
2100001688
我试探着:
substr(pck_import.GETdocnumber(XML_DATA),
instr(pck_import.GETdocnumber(XML_DATA),
'DL:') + 3))
这也会传回“Pr:“。
3条答案
按热度按时间sbtkgmzw1#
5sxhfpxr2#
像这样的东西?
示例数据:
查询:
(note如果您要处理的数据不止一行,则可能需要修改该查询)
np8igboo3#
You could achieve this by using regular expressions utilising a positive lookbehind and lookahead.
The regex
(?<=DL\:)\d*(?=\s)'
matches all digits betweenDL:
until a single whitespace character occurs.You'd want to use the
REGEXP_SUBSTR
function for this (as you tagged this question with OracleSQL):If you want to match substrings like
DST22017260
as well, using.
(any character) instead of\d
would work:(?<=DL\:).*(?=\s)
.