从字符串中获取特定单词,ORACLE
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10069733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
get specific words from string , ORACLE
提问by Ahmed Dimah
Kindly are there any one knows how to get a specific string from a huge string using pl/sql, I'm some kind beginner in creating querys,so any help will be useful. BTW i don't want to use the function : select substr( *, * ,* ) from * cuz the input is variable, so can any one help me on this problem, and do you advice me to use block instate of that.
请问有没有人知道如何使用pl/sql从一个巨大的字符串中获取一个特定的字符串,我是创建查询的初学者,所以任何帮助都会有用。顺便说一句,我不想使用这个函数: select substr( *, * ,* ) from * 因为输入是可变的,所以任何人都可以帮助我解决这个问题,你是否建议我使用块状态。
Thanks & regards,
感谢和问候,
回答by Dan A.
It sounds like you're looking for a specific string inside of a bigger string. If so, the function you're probably looking for is INSTR:
听起来您正在寻找更大字符串中的特定字符串。如果是这样,您可能正在寻找的函数是 INSTR:
http://docs.oracle.com/cd/B28359_01/olap.111/b28126/dml_functions_1103.htm
http://docs.oracle.com/cd/B28359_01/olap.111/b28126/dml_functions_1103.htm
回答by Gaurav Soni
As far my understanding to your question you want to check
whether a specific word
is present in a string or not
,if this is the question you can find the solution below .
就我对您的问题的理解而言,您想check
知道 a 中specific word
是否存在 a string or not
,如果这是问题,您可以在下面找到解决方案。
DECLARE
v_string VARCHAR2(200):='MY NAME IS GAURAV SONI';
v_check PLS_INTEGER;
BEGIN
v_check:=INSTR(v_string,'GAURAV'); --this is case sensitive
IF v_check >0 THEN
dbms_output.put_line('Word exists');
END IF;
END;
In the above block we are searching Word GAURAV
in the String MY NAME IS GAURAV SONI
and this word exist in 12
place .
在上面的块中,我们GAURAV
在 String中搜索 WordMY NAME IS GAURAV SONI
并且这个词12
就地存在。
Please note this is Case sensitive
and if you put word gaurav
,value of v_check
will be zero
.
请注意这是Case sensitive
,如果您输入单词gaurav
,则值v_check
将是zero
。
If you are are looking for Case insensitive
then go for REGULAR EXPRESSIONS in oracle REGEXP_INSTR
in place of INSTR
.Read the oracle document before using this function REGEXP_INSTR
如果你正在寻找Case insensitive
然后去 oracleREGEXP_INSTR
中的REGULAR EXPRESSIONS代替INSTR
。 在使用这个函数REGEXP_INSTR之前阅读 oracle 文档