Oracle中REGEXP_SUBSTR的正则表达式 [英] Regular Expression for REGEXP_SUBSTR in Oracle

查看:194
本文介绍了Oracle中REGEXP_SUBSTR的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要搜索以下文本:

#S7Z OK
#Wed Feb 18 07:16:26 GMT 2015
expiration=10.0
lastModified=1424192425832
length=466472
path=/name/_master_/563/5638ad54-8079-4399-ba2b-3257b6e6c7fd.pdf 
userType=

每个=后面的单词是属性的名称.对于每个属性名称,我想获取属性值.这意味着我正在寻找一个与regexp_substr一起使用的正则表达式,以获取每个已知属性的值.

The words proceeding each = are the names of properties. For each property name, I'd like to get the property value. That means I'm looking for a regular expression to use with regexp_substr to get the value of each known property.

类似这样的东西:

SELECT REGEXP_SUBSTR(
'#S7Z OK
#Wed Feb 18 07:16:26 GMT 2015
expiration=10.0
lastModified=1424192425832
length=466472
path=/name/_master_/563/5638ad54-8079-4399-ba2b-3257b6e6c7fd.pdf 
userType=',
'path=.+')
FROM dual

返回: 路径=/名称/主控/563/5638ad54-8079-4399-ba2b-3257b6e6c7fd.pdf

which returns: path=/name/master/563/5638ad54-8079-4399-ba2b-3257b6e6c7fd.pdf

但是我只想要一个值,即"/name/master/563/5638ad54-8079-4399-ba2b-3257b6e6c7fd.pdf". 它也应该适用于到期时间,lastModified等,也就是说,我不仅要搜索url,而且要搜索任何类型的值.

But I only want the value, that is "/name/master/563/5638ad54-8079-4399-ba2b-3257b6e6c7fd.pdf ". It should also work for expiration, lastModified etc., that is, I don't just want to search for a url but any kind of value.

如何用一个正则表达式实现呢?

How can I achieve that in one regular expression?

推荐答案

SELECT REGEXP_SUBSTR(
'#S7Z OK
#Wed Feb 18 07:16:26 GMT 2015
expiration=10.0
lastModified=1424192425832
length=466472
path=/name/_master_/563/5638ad54-8079-4399-ba2b-3257b6e6c7fd.pdf 
userType=',
'path=(.+)', 1, 1, null, 1)
FROM dual;

这篇关于Oracle中REGEXP_SUBSTR的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆