从SQL中的STRING中提取数据

时间:2022-09-13 13:21:54

How to extract the data in string? For example below is the string format:

如何在字符串中提取数据?例如,下面是字符串格式:

" in: xyz: abhi , product: NR (Ritti) ''

I want the output as Ritti from the above string.

我想从上面的字符串输出Ritti。

Please help. Thanks in advance

请帮忙。提前致谢

2 个解决方案

#1


0  

If there is only one bracket closed value in the string then this can be useful. for Oracle -

如果字符串中只有一个括号闭合值,那么这可能很有用。对于甲骨文 -

with string_value(str) as(
select 'in: xyz: abhi , product: NR (Ritti)' from dual
)
select substr(str,instr(str,'(')+1,instr(str,')',1)-instr(str,'(',1)-1) from string_value; 

#2


0  

You might try:

你可以尝试:

select regexp_replace('in: xyz: abhi , product: NR (Ritti)','.*\((.*)\).*','\1') from dual;

#1


0  

If there is only one bracket closed value in the string then this can be useful. for Oracle -

如果字符串中只有一个括号闭合值,那么这可能很有用。对于甲骨文 -

with string_value(str) as(
select 'in: xyz: abhi , product: NR (Ritti)' from dual
)
select substr(str,instr(str,'(')+1,instr(str,')',1)-instr(str,'(',1)-1) from string_value; 

#2


0  

You might try:

你可以尝试:

select regexp_replace('in: xyz: abhi , product: NR (Ritti)','.*\((.*)\).*','\1') from dual;