我需要将一个字符串解析112^3^1^1^
为单独的值。
第一个('112')是order_no,第二个是line_no,第三个是release_no,第四个是receipt_no。
我可以在 Oracle 中使用什么样的正则表达式?
with demo (str) as
( select '112^3^1^1^' from dual )
select str
, regexp_substr(str,'[^^]+',1,1) as order_no
, regexp_substr(str,'[^^]+',1,2) as line_no
, regexp_substr(str,'[^^]+',1,3) as release_no
, regexp_substr(str,'[^^]+',1,4) as receipt_no
from demo;
STR ORDER_NO LINE_NO RELEASE_NO RECEIPT_NO
---------- ---------- --------- ------------ ----------
112^3^1^1^ 112 3 1 1
这取决于每个组件都有一个值,因为它使用的模式是'一个或多个不是^
' 的字符。如果缺少某个值,则需要进行一些调整,例如'112^3^^1^'
(无 release_no)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句