从给定字符串中提取子字符串 [英] Exracting substring from given string
本文介绍了从给定字符串中提取子字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下数据
1)MAXO_INSTR_INTERFACE
2)MAXIS_VENDOR_INTERFACE
3)MAXIMOS_EMPS_INTERFACE2
我需要将位于PL/SQL中两个下划线之间的字符串提取为
I need to extract String which is located between both underscores in PL/SQL as
INPUT EXPECTED OUTPUT
------------------------ ---------------
MAXO_INSTR_INTERFACE INSTR
MAXIS_VENDOR_INTERFACE VENDOR
MAXIMOS_EMPS_INTERFACE2 EMPS
我尝试过使用子字符串功能,但是我无法准确执行.
I have tried with substring function but i am unable to perform accurately.
推荐答案
一个稍微容易一些的正则表达式:
A slightly easier regular expression:
SQL> with t as
2 ( select 'maxo_instr_interface' as txt from dual union all
3 select 'maxis_vendor_interface' from dual union all
4 select 'maximos_emps_interface2' from dual
5 )
6 select txt
7 , regexp_substr(txt,'[^_]+',1,2)
8 from t
9 /
TXT REGEXP_SUBSTR(TXT,'[^_]
----------------------- -----------------------
maxo_instr_interface instr
maxis_vendor_interface vendor
maximos_emps_interface2 emps
3 rows selected.
关于,
罗布.
Regards,
Rob.
这篇关于从给定字符串中提取子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文