Oracle REGEXP_SUBSTR |获取两个分隔符之间的字符串 [英] Oracle REGEXP_SUBSTR | Fetch string between two delimiters

查看:63
本文介绍了Oracle REGEXP_SUBSTR |获取两个分隔符之间的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串 Organization, INC..Truck/Equipment Failure |C.我想在组织名称之后(在两个 '..' 字符之后)和管道字符之前获取子字符串.所以输出字符串应该是 - Truck/Equipment Failure.你能帮忙吗.

I have a string Organization, INC..Truck/Equipment Failure |C. I want to fetch the sub-string after organization name (after two '..' characters) and before pipe character. So the output string should be - Truck/Equipment Failure. Can you please help.

我一直在尝试形成这样的正则表达式,但似乎不起作用.

I have been trying forming regexp like this but doesn't seem working.

select regexp_substr('Organization, INC..Truck/Equipment Failure |C', '[^.]+',1,2) from dual;

推荐答案

你可以使用这个.

SELECT REGEXP_SUBSTR ('Organization, INC..Truck/Equipment Failure |C',
                      '([^.]+)\|',
                      1,
                      1,
                      NULL,
                      1)
  FROM DUAL;

这将精确匹配两个点,后跟一个或多个除 | 之外的字符,直到字符串结束.

This will match exactly two dots followed by one or more characters other than a | till the end of string.

SELECT REGEXP_SUBSTR ('Organization, INC..Truck/Equipment Failure',
                      '\.{2}([^|]+)',
                      1,
                      1,
                      NULL,
                      1)
  FROM DUAL;

演示

这篇关于Oracle REGEXP_SUBSTR |获取两个分隔符之间的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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