How to use INSTR() and SUBSTR()

454 views Asked by At

I have a small example, of how to use INSTR() and SUBSTR() My example:

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);

I wish to have a result like: test = 3. But my result is: test = 3" Can someone explain where is my mistake?

1

There are 1 answers

0
Silviu On BEST ANSWER
f_property_value:= REGEXP_REPLACE(SUBSTR(V1,(apostrophe1)+1,(apostrophe2)-2),'"',''); 

It is working with this.