-2
我如何使用INSTR()
和SUBSTR()
我的例子一个小例子,:如何使用INSTR()和SUBSTR()
String = 'test = "2"';
apostrophe1:= INSTR(String,'"',1,1);
apostrophe2:= INSTR(String,'"',1,2);
equal:= INSTR(String,'=',1,1);
f_property_name:= SUBSTR(V1,1,equal-2);
f_property_value:= SUBSTR(V1,(apostrophe1)+1,(apostrophe2)-2);
dbms_output.put_line(f_property_name||' = '||f_property_value);
我想有这样的结果:test = 3
。 但我的结果是:test = 3"
有人可以解释我的错误在哪里?
你应该学会使用正则表达式函数,特别是'regexp_replace()'。显然这个问题是一个错误的错误,应该很容易通过从某个东西中减去1来解决。 –
我忘了提。我也试过,你是ideea但不工作。我有同样的结果,甚至减去-4。出于这个原因,我不明白为什么不工作。 该字符串来自一行文本文件,也许从这里是问题。 – Silviu
f_property_value:= REGEXP_REPLACE(SUBSTR(V1,(撇号1)+1,(撇号2)-2),'''''');谢谢,man!即使你减去我的尊重点:) – Silviu